Skip to content

Commit b2f1c80

Browse files
perf: Add composite index on jobs table for efficient job fetching
Add INDEX (status, priority, scheduled_time) to optimize the critical populate query: SELECT ... FROM jobs WHERE status='pending' AND scheduled_time <= NOW() ORDER BY priority ASC, scheduled_time ASC This index covers the WHERE clause and ORDER BY, eliminating table scans and filesorts for large job queues. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c738cae commit b2f1c80

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/datajoint/jobs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def _generate_definition(self) -> str:
168168
pid=0 : int32
169169
connection_id=0 : int64
170170
version="" : varchar(64)
171+
INDEX (status, priority, scheduled_time)
171172
"""
172173

173174
def _get_fk_derived_pk_attrs(self) -> list[tuple[str, str]]:

0 commit comments

Comments
 (0)