perf(finding): add sla_expiration_date index for global finding list#15103
Merged
Conversation
Maffooch
approved these changes
Jun 29, 2026
valentijnscholten
approved these changes
Jun 30, 2026
Jino-T
approved these changes
Jul 1, 2026
Contributor
|
I'm gonna rebase this to dev so that the migrations line up a bit easier for the release on Monday |
The global finding list ordered by sla_expiration_date seq-scanned and sorted the entire authorized finding set on every page load. Add a full (non-partial) btree on sla_expiration_date so the planner can walk the index and stop at the LIMIT instead. The existing partial idx_finding_sla_open_cov cannot serve this query because the query has no is_mitigated predicate. Measured on a 10M-finding clone, global finding list ORDER BY sla_expiration_date ASC LIMIT 25 (per-user authorization filter), under load test: - Before: mean 6591 ms, max 20732 ms, total 1582 s - After: mean 115 ms, max 4992 ms, total 96 s (~57x mean improvement; the query dropped from the #1 offender to negligible). Index size ~68 MB on the clone. Built CONCURRENTLY (atomic = False) so the migration takes no ACCESS EXCLUSIVE lock on the large dojo_finding table. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
970baef to
e585358
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a full (non-partial) btree on
dojo_finding.sla_expiration_date.The global finding list ordered by
sla_expiration_datewas seq-scanning and sorting the entire authorized finding set on every page load (the order column had no walkable index). This index lets the planner walk it and stop at theLIMITinstead.The existing partial
idx_finding_sla_open_cov(WHERE NOT is_mitigated) cannot serve this query because the query has nois_mitigatedpredicate — hence a plain full index.Performance (measured on a 10M-finding clone, under load test)
Query: global finding list
ORDER BY sla_expiration_date ASC LIMIT 25with the per-user authorization filter.idx_finding_sla_exp→ nested-loop probe → stop at 25~57× mean improvement; the query dropped from the #1 offender to negligible. Index size ~68 MB on the clone.
Notes
CONCURRENTLY(atomic = False) → noACCESS EXCLUSIVElock on the largedojo_findingtable.0271_finding_perf_indexes), which this depends on.models.Indexadded toFinding.Meta.indexesto keep model/migration state in sync.🤖 Generated with Claude Code