Part of #7494. The landings query in src/flow/kpis.ts has a per-row NOT EXISTS that scans pull joined to issue for each landing, to drop duplicate merged_oids. It is the likeliest cost of the 4.4 s.
Done when:
[ ] The landings are read in one pass. For example: take the pulls merged in the window, then keep the first per (repo, merged_oid) in TypeScript, or use GROUP BY with MIN(merged_at).
[ ] The counts match today's for the same data: the existing kpi tests pass unchanged.
[ ] A new test seeds 20,000 merged pulls and checks that readKpis answers in under 100 ms against the baselineMs floor.
[ ] No new migration. If an index is truly needed, the pull says why, and the pin and migration land together with the production-size home test green.
Files: src/flow/kpis.ts, one test.
Risk: a duplicate merged oid counted twice; cover it in the test.
Part of #7494. The landings query in
src/flow/kpis.tshas a per-rowNOT EXISTSthat scanspulljoined toissuefor each landing, to drop duplicatemerged_oids. It is the likeliest cost of the 4.4 s.Done when:
GROUP BYwithMIN(merged_at).readKpisanswers in under 100 ms against thebaselineMsfloor.Files: src/flow/kpis.ts, one test. Risk: a duplicate merged oid counted twice; cover it in the test.