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

N+1 Queries pointing to line of code #42977

Closed
realkosty opened this issue Jan 9, 2023 · 9 comments
Closed

N+1 Queries pointing to line of code #42977

realkosty opened this issue Jan 9, 2023 · 9 comments
Labels
Product Area: Performance Sync: Jira Apply to auto-create a Jira shadow ticket

Comments

@realkosty
Copy link
Contributor

realkosty commented Jan 9, 2023

Problem Statement

Prospective customer would like Sentry's N+1 Query performance issue to point to the line of code where the offending query appears in their code. They have recently become aware there are a lot of places in their code where it happens and it would make it easier if Sentry let them immediately correct this without having to search across a large number of potentially similar-looking database queries (please see Jira ticket for details).

Solution Brainstorm

No response

┆Issue is synchronized with this Jira Improvement by Unito

@realkosty realkosty added the Sync: Jira Apply to auto-create a Jira shadow ticket label Jan 9, 2023
@realkosty
Copy link
Contributor Author

Potential workaround could be using something like the Bullet library for Ruby (integrates with Sentry): https://github.com/flyerhzm/bullet

@dalezak
Copy link

dalezak commented Jan 10, 2023

Bullet integration with Sentry would work great in development or staging environments, however Bullet doesn't recommend enabling it in production environments due to performance impact. So seeing code snippet related to N+1 queries would still be very valuable in Sentry.

@getsantry
Copy link
Contributor

getsantry bot commented Jan 13, 2023

Routing to @getsentry/visibility for triage, due by Tue Jan 17 2023 19:35:51 GMT+0000. ⏲️

@narsaynorath
Copy link
Member

Added feature request and backlog labels for now. Albert's on the corresponding Jira ticket and aware of this

@leoplct
Copy link

leoplct commented Oct 24, 2023

+1 it’s supported by ScoutAPM and it’s great! Very easy to find how to fix. With the current Sentry solution is a pain to find what is the line of code causing the issue.

@getsantry
Copy link
Contributor

getsantry bot commented Oct 25, 2023

Routing to @getsentry/product-owners-performance for triage ⏲️

@realkosty
Copy link
Contributor Author

This is now supported for Django and Laravel: #62118

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 2 Feb 3, 2024
@gggritso
Copy link
Member

gggritso commented Feb 5, 2024

Yep, this is supported in Sentry now, but with a caveat: collecting query sources has performance overhead, so we only do it for slow queries where the query's duration outweighs the performance overhead of collecting the query source.

We set a threshold for the minimum query duration depending on the framework: 100ms by default in all Python frameworks, 0ms in Laravel. N+1 queries are often pretty fast (much faster than 100ms), it's their amount that matters. In this case, in order to get query sources, customers might need to set a very low threshold. If they do this, it's a good idea to keep an eye on overall app performance.

Maybe turning down the threshold temporarily to find the source of the queries is a good idea in this case.

Also, the customer who filed the issue is using a Ruby framework, which we don't support yet, tracking that as a feature request here: getsentry/sentry-ruby#2242

@realkosty
Copy link
Contributor Author

@gggritso thanks for the details, super helpful!

@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Product Area: Performance Sync: Jira Apply to auto-create a Jira shadow ticket
Projects
Archived in project
Archived in project
Development

No branches or pull requests