Skip to content

Commit 4632343

Browse files
committed
database: Add index to optimize background job queue processing
This commit creates a composite index on `(priority DESC, id ASC)` to improve performance of job selection queries that order by priority and id for queue processing. This improved the job selection query performance from roughly 800ms to 0.07ms after enqueuing all of the `analyze-crate-file` backfill background jobs.
1 parent 8cae1a9 commit 4632343

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP INDEX CONCURRENTLY background_jobs_priority_id_index;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
run_in_transaction = false
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CREATE INDEX CONCURRENTLY background_jobs_priority_id_index
2+
ON background_jobs (priority DESC, id ASC);

0 commit comments

Comments
 (0)