Skip to content

perf(finding): add sla_expiration_date index for global finding list#15103

Merged
Maffooch merged 2 commits into
devfrom
ree/perf-finding-sla-index
Jul 1, 2026
Merged

perf(finding): add sla_expiration_date index for global finding list#15103
Maffooch merged 2 commits into
devfrom
ree/perf-finding-sla-index

Conversation

@rossops

@rossops rossops commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds a full (non-partial) btree on dojo_finding.sla_expiration_date.

The global finding list ordered by sla_expiration_date was 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 the LIMIT instead.

The existing partial idx_finding_sla_open_cov (WHERE NOT is_mitigated) cannot serve this query because the query has no is_mitigated predicate — 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 25 with the per-user authorization filter.

Plan Mean Max Total
Before Parallel Seq Scan (3.4M rows) → hash join → sort 6591 ms 20732 ms 1582 s
After Index Scan on idx_finding_sla_exp → nested-loop probe → stop at 25 115 ms 4992 ms 96 s

~57× mean improvement; the query dropped from the #1 offender to negligible. Index size ~68 MB on the clone.

Notes

  • Built CONCURRENTLY (atomic = False) → no ACCESS EXCLUSIVE lock on the large dojo_finding table.
  • Follows the pattern established in Ree/perf indexes #15095 (0271_finding_perf_indexes), which this depends on.
  • Companion models.Index added to Finding.Meta.indexes to keep model/migration state in sync.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the New Migration Adding a new migration file. Take care when merging. label Jun 29, 2026
@rossops rossops changed the base branch from bugfix to dev June 29, 2026 17:43
@rossops rossops changed the base branch from dev to bugfix June 29, 2026 17:43
@Maffooch Maffooch added this to the 3.1.0 milestone Jun 29, 2026

@mtesauro mtesauro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@Maffooch

Maffooch commented Jul 1, 2026

Copy link
Copy Markdown
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>
@Maffooch Maffooch force-pushed the ree/perf-finding-sla-index branch from 970baef to e585358 Compare July 1, 2026 22:11
@Maffooch Maffooch changed the base branch from bugfix to dev July 1, 2026 22:11
@Maffooch Maffooch merged commit 5fc11c8 into dev Jul 1, 2026
149 of 150 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Migration Adding a new migration file. Take care when merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants