DB: indexes for the polling queries

- jobs(finished_at): the live view's "open or finished in the last 5 minutes"
  query, run once a second per visible tab, was a full scan of the job
  history; it is now a multi-index lookup (0.23 -> 0.04 ms at 2,000 jobs).
- benchmark_runs(state, created_at): the worker's look for the next queued run
  every 2 s scanned every run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EooZ9biu7kFNB4eDJrwQc5
This commit is contained in:
Claude committed 2026-11-01 21:04:45 +00:00
1 parent 6f4932e04d
commit 6b779debf7
5 files changed
+1549 -2

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
CREATE INDEX `benchmark_runs_state_idx` ON `benchmark_runs` (`state`,`created_at`);--> statement-breakpoint
CREATE INDEX `jobs_finished_idx` ON `jobs` (`finished_at`);