feat(perf): New indexes for job pickup & monitoring #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is the first of several query optimizations, and can largely be read in two parts:
READMEw/ some expanded instructions andEXPLAINsnapshots, which seems to improve numerous plans without regressing any. (I haven't yet removed the old index, of course, but that's the eventual goal, once I make a few more query changes.)(Non-AI) Summary of EXPLAIN changes:
failed_at IS NULLis no loner necessary in theFilter:, and when a single queue is specified, it gets promoted to anIndex Cond:SCAN ... USING INDEXeither way (doesn't reveal more than that)Table scanbecomesIndex lookup💪 with bothfailed_atandqueuein the index conditions! (ASortis also completely avoided as it's able to use the pre-sorted index now.)failed_atis no longer necessary inFilter:clauses.failed_countgoes fromSeq ScantoIndex Only Scan💯max_lock_ageandworking_countgo fromSeq ScantoIndex Scan👍SCAN delayed_jobs ...becomesSCAN delayed_jobs USING INDEX ...countandfuture_countgo fromTable scantoCovering index scanfailed_countgoes fromTable scantoCovering index range scanmax_lock_age,max_age,working_count,workable_count, andalert_age_percentgo fromTable scantoIndex lookupw/ index conditions/no-platform