Commit afe280c
committed
perf(database): index BatchTaskRun on (runtimeEnvironmentId, createdAt, id) for the batches list
The batches list page orders by createdAt DESC, id DESC filtered by
environment and a created-at window, but the only matching index was
(runtimeEnvironmentId, id), which cannot satisfy the createdAt ordering.
On environments with many batches the query fell back to a full table
scan and in-memory sort, which could run long enough to hit the
statement timeout.
Adds (runtimeEnvironmentId, createdAt DESC, id DESC) so the query reads
straight from the index in order. Created with CONCURRENTLY IF NOT
EXISTS, so it takes no table lock and is a no-op if already present.1 parent 722e240 commit afe280c
3 files changed
Lines changed: 9 additions & 0 deletions
File tree
- .server-changes
- internal-packages/database/prisma
- migrations/20260724120000_add_batch_task_run_created_at_dashboard_index
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1935 | 1935 | | |
1936 | 1936 | | |
1937 | 1937 | | |
| 1938 | + | |
1938 | 1939 | | |
1939 | 1940 | | |
1940 | 1941 | | |
| |||
0 commit comments