Reduce over-fetching in Bugscache queries#9554
Open
camd wants to merge 1 commit into
Open
Conversation
Bugscache.search() and the create_bug endpoint loaded full Bugscache rows when only a subset of columns is actually used: - search(): defer `modified` and `processed_update` via .only(), since serialize() excludes them anyway. Remove the dead `jobmap` entry from the serialize() exclude list (a reverse relation model_to_dict never iterates). - create_bug: resolve the existing bug id with values_list() instead of fetching the whole row, restrict the summary fallback query with .only(), and limit the linking save() to the two changed columns via update_fields. Add tests covering the create_bug internal-id resolution paths.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9554 +/- ##
==========================================
+ Coverage 82.94% 82.96% +0.02%
==========================================
Files 613 613
Lines 35372 35394 +22
Branches 3208 3206 -2
==========================================
+ Hits 29338 29364 +26
+ Misses 5880 5876 -4
Partials 154 154 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Bugscache.search()(backing the bug-suggestions endpoint) and thecreate_bugendpoint both loaded fullBugscacherows when only a subset of columns is actually used. This trims the fetched/written columns without changing behavior.Changes
Bugscache.search()— add.only(...)to defermodifiedandprocessed_update, whichserialize()excludes anyway. TheTrigramSimilarityannotation andserialize()output are unaffected.Bugscache.serialize()— remove the dead"jobmap"entry fromexclude_fields; it's a reverse relation thatmodel_to_dictnever iterates, so it had no effect.create_bug— resolve the existing internal id withvalues_list("id", flat=True).first()instead of fetching the whole row; restrict the summary-fallback query with.only("id", "bugzilla_id", "modified"); and limit the linkingsave()to the two changed columns viaupdate_fields.Tests
Added coverage for the
create_buginternal-id resolution paths (existing bug matched bybugzilla_id, and an internal bug linked bysummary), which were previously untested.Notes
This is the over-fetch portion of a broader Bugscache query audit. A separate, layered PR adds a GIN trigram index on
bugscache.summary(the substring/similarity search currently can't use the existing btree index) — kept separate so the index change can be measured and reviewed on its own.