perf(jira,product): fix finding-group push N+1 and add case-insensitive product-name index#15122
Open
Maffooch wants to merge 4 commits into
Open
perf(jira,product): fix finding-group push N+1 and add case-insensitive product-name index#15122Maffooch wants to merge 4 commits into
Maffooch wants to merge 4 commits into
Conversation
Fixes DJANGO-42P8.
push_finding_group_to_jira loaded the group without prefetching its findings,
so the JIRA helpers it fans out to (jira_description, jira_priority,
get_sla_deadline, get_labels, get_tags, ...) each re-ran
finding_group.findings.all(), producing an N+1 on dojo_finding_group_findings.
Load the group with prefetch_related('findings') so those reads hit the cache.
Guarded by a query-count regression test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…lookup Fixes DJANGO-D2M. Filtering findings by product name issues WHERE UPPER(dojo_product.name) = UPPER(%s), which the plain unique btree on name can't serve, causing a slow sequential scan. Add a functional Upper(name) index (created CONCURRENTLY). Guarded by a schema regression test asserting the index exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Fix docstring summary placement (D213), drop unused noqa directives, and move the jira helper import to top-level (the Django test runner has apps loaded, so the lazy import is unnecessary). No behavior change; both tests still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Comment on lines
+33
to
+35
| The real helpers read finding_group.findings.all() several times; if the | ||
| group is prefetched those reads hit the prefetch (0 queries). Without the | ||
| fix each read is a fresh dojo_finding_group_findings query (N+1). |
Member
There was a problem hiding this comment.
Does/Did it really execute a new query everytime .all() is called? Usually django caches it after the first time is what I thought?
Contributor
Author
There was a problem hiding this comment.
I was under that impression as well. Maybe it is different for m2m relationships? This performance issue was raised by sentry that also looks at SQL queries
valentijnscholten
approved these changes
Jul 1, 2026
dojo_testdata.json can't load under V3_FEATURE_LOCATIONS (Endpoint model deprecated), which failed setUpClass on the V3 CI matrix variant. Apply the standard @versioned_fixtures decorator so it loads dojo_testdata_locations.json under V3. Verified passing under both V3_FEATURE_LOCATIONS true and false. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dogboat
approved these changes
Jul 1, 2026
Jino-T
approved these changes
Jul 1, 2026
rossops
approved these changes
Jul 1, 2026
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.
Shortcut: sc-13412
Two focused fixes for Sentry `db_query` issues.
Fixes
Testing
🤖 Generated with Claude Code