chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
A pull's checks are read from the index on its pull
Merged Approved
This pull adds a check_pull_at index on (json_extract(value,'$.pull'), started_at, uri). When a pull filter is given, the checks statement now names that index with INDEXED BY. Other filters still use the old repository-ordered form. I read the diff and found nothing that must change.
- Behaviour: Both branches keep the same
WHEREclauses andORDER BY started_at DESC, uri DESC. The?9 IS NULLcondition moves into theNoneform, so it stays valid there. - Planner: The
+repo_didmark and the expression written exactly as in the index follow AGENTS.md's Queries guidance. INDEXED BY: It errors if the index is missing, but the index is created withIF NOT EXISTSalongside the others, so existing databases get it too.- Checks: I did not read the CI results. The
testplans gate is what proves the new plan avoids a scan or sort, so make sure it passes before merging. - Optional:
check_pullstays because another query uses it, so every run write now maintains two indexes on the pull. That's acceptable.
All checks have passed
8 passed, 2 skipped
Merged as 193c796
What changes
When the index is asked for a pull's checks, it now reads them through a new index,
check_pull_at(json_extract(value, '$.pull'), started_at, uri), newest first. Before, it walked the repository's runs newest first and kept the few that were that pull's. Any other filter is read as before. The answer is the same.Why
On prod today the checks statement ran 91 times, with a mean of 321ms and a max of 747ms. getMergeStatus, getQueue, a pull's page and the checks tool all ask for one pull's checks. A
check_pullindex on the pull was already there, but(?9 IS NULL OR json_extract(value, '$.pull') = ?9)keeps SQLite from using it, so it walkedcheck_repo. chadtmiller.com/knotless gets about 1,400 runs a day, so that walk grows with every run. The pull's form now names its index, and the new index keeps the order the statement sorts by, so nothing is sorted.How it was checked
The serve tests that read a pull's checks (merge status, the queue, checks by pull) cover both forms. The plans gate in
testplans both at prod's sizes. Running it is left to CI. After deploy, the check is the statement's mean instats, against 321ms.Shortcomings
A filter by workflow alone, as the runs page asks for, still walks the repository's runs. That page is seldom read.
🤖 Generated with Claude Code