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

Optimize duplicate queries occurring in AlertGroupFilter #1809

Merged
merged 5 commits into from
Apr 26, 2023

Conversation

joeyorlando
Copy link
Contributor

@joeyorlando joeyorlando commented Apr 21, 2023

What this PR does

In AlertGroupFilter we currently have 11 duplicate queries which add ~1-2secs of unecessary request latency to GET /api/internal/v1/alertgroups calls.
Screenshot 2023-04-20 at 17 57 49

The queries originate from the queryset callable arguments on several of the fields of the AlertGroupFilter class. These callables basically filter down their respective querysets to include only objects that belong to the currently authenticated user's organization.

The duplicate queries are

  • 2 queries to fetch integrations
  • 2 queries to fetch escalation chains
  • 10 queries to fetch users

At the moment, this PR is still a draft and doesn't work as intended. It's based off of a suggestion from this discussion in the django-filter repo. See this DjangoCon talk for more context.

@iskhakov iskhakov changed the title WIP: optimize duplicate queries occurring in AlertGroupFilter Pptimize duplicate queries occurring in AlertGroupFilter Apr 26, 2023
@iskhakov iskhakov marked this pull request as ready for review April 26, 2023 06:05
@iskhakov iskhakov requested a review from a team as a code owner April 26, 2023 06:05
@iskhakov iskhakov enabled auto-merge April 26, 2023 06:06
@iskhakov iskhakov changed the title Pptimize duplicate queries occurring in AlertGroupFilter Optimize duplicate queries occurring in AlertGroupFilter Apr 26, 2023
@iskhakov iskhakov added the pr:no public docs Added to a PR that does not require public documentation updates label Apr 26, 2023
@iskhakov iskhakov added this pull request to the merge queue Apr 26, 2023
Merged via the queue into dev with commit 52ff041 Apr 26, 2023
20 of 21 checks passed
@iskhakov iskhakov deleted the jorlando/improve-alert-group-filterset-queries branch April 26, 2023 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:no public docs Added to a PR that does not require public documentation updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants