Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(index): Add indexes for the upkeep queries that run #194

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

evanh
Copy link
Member

@evanh evanh commented Feb 19, 2025

The queries that the upkeep thread uses have different indexes from the get pending activation query. Add more indexes to account for those queries as well.

These were tested locally, just to ensure that they get used as expected.

sqlite> EXPLAIN QUERY PLAN UPDATE inflight_taskactivations SET processing_deadline = null, status = "Failure" WHERE processing_deadline < now() and at_most_once = TRUE AND status = "Processing";
QUERY PLAN
`--SEARCH inflight_taskactivations USING INDEX idx_processing_deadline (status=? AND processing_deadline<?)

sqlite> EXPLAIN QUERY PLAN UPDATE inflight_taskactivations SET status = "FAILURE" WHERE processing_attempts >= 10 AND status = "PROCESSING";
QUERY PLAN
`--SEARCH inflight_taskactivations USING INDEX idx_processing_attempts (status=? AND processing_attempts>?)

sqlite> EXPLAIN QUERY PLAN UPDATE inflight_taskactivations SET status = "FAILURE" WHERE expires_at IS NOT NULL AND expires_at < 1713686400 AND status = "PROCESSING";
QUERY PLAN
`--SEARCH inflight_taskactivations USING INDEX idx_expires_at (status=? AND expires_at>? AND expires_at<?)

The queries that the upkeep thread uses have different indexes from the get pending activation
query. Add more indexes to account for those queries as well.
@evanh evanh requested a review from a team as a code owner February 19, 2025 18:05
@evanh evanh merged commit f7febfc into main Feb 19, 2025
11 checks passed
@evanh evanh deleted the evanh/fix/index-for-upkeep branch February 19, 2025 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants