Open
Conversation
Looking at the performance degradation in NR, the problem didn't seem to be a "query" problem in so far as NR didn't show elevated database times. Looking at the code, this led me to believe the degradation (~20ms avg) from the previous change was due to python deserializing too many objects from the database. After discussion with the ol' AI (Gemini), this change should avoid deserializing a pretty large number of objects and be similar to what we had before. Previously, we were requesting every ad and its ad types for each ad from each candidate flight. Assuming 3 ad types per ad and ~30 flights and ~4 ads per flight, we're looking at ~350 more objects being deserialized from the DB. The query itself didn't appear more expensive, but turning that data into Django model objects was. That's at least the working theory. I have verified that this change looks good from a query perspective and I reviewed every query in the critical path.
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.
Looking at the performance degradation in NR, the problem didn't seem to be a "query" problem in so far as NR didn't show elevated database times. Looking at the code, this led me to believe the degradation (~20ms avg) from the previous change was due to python deserializing too many objects from the database.
After discussion with the ol' AI (Gemini), this change should avoid deserializing a pretty large number of objects and be similar to what we had before. Previously, we were requesting every ad and its ad types for each ad from each candidate flight. Assuming 3 ad types per ad and ~30 flights and ~4 ads per flight, we're looking at ~350 more objects being deserialized from the DB. The query itself didn't appear more expensive, but turning that data into Django model objects was. That's at least the working theory.
I have verified that this change looks good from a query perspective and I reviewed every query in the critical path.
References