Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: N+1 on segment overrides for environment-document endpoint #3512

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

matthewelwell
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

Fixes an N+1 issue on environment-document endpoint caused by retrieving the environment for each segment override.

How did you test this code?

Updated the test for the environment-document endpoint to include segment overrides. Confirmed that the number of queries increased linearly with the number of segment overrides, then reduced once the new select related argument was added.

@matthewelwell matthewelwell requested a review from khvn26 February 29, 2024 23:54
Copy link

vercel bot commented Feb 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 1, 2024 0:16am
flagsmith-frontend-preview ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 1, 2024 0:16am
flagsmith-frontend-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 1, 2024 0:16am

@github-actions github-actions bot added the api Issue related to the REST API label Feb 29, 2024
# and the relevant URL to get an environment document
url = reverse("api-v1:environment-document")

# When
with django_assert_num_queries(11):
with django_assert_num_queries(13):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This number increased to 23 before I added the select related. I think the additional 2 queries are legitimate for retrieving the MV data and the segment overrides.

Copy link
Contributor

github-actions bot commented Feb 29, 2024

Uffizzi Preview deployment-47593 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.85%. Comparing base (e2893d1) to head (295971f).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3512   +/-   ##
=======================================
  Coverage   95.85%   95.85%           
=======================================
  Files        1097     1097           
  Lines       34117    34125    +8     
=======================================
+ Hits        32704    32712    +8     
  Misses       1413     1413           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants