Commit 5fc11c8
perf(finding): add sla_expiration_date index for global finding list (DefectDojo#15103)
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>
Co-authored-by: Cody Maffucci <46459665+Maffooch@users.noreply.github.com>1 parent 9a2f377 commit 5fc11c8
2 files changed
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
511 | 511 | | |
512 | 512 | | |
513 | 513 | | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
514 | 523 | | |
515 | 524 | | |
516 | 525 | | |
| |||
0 commit comments