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 query tracking in production #22

Open
thawatchai opened this issue Apr 2, 2020 · 1 comment
Open

n+1 query tracking in production #22

thawatchai opened this issue Apr 2, 2020 · 1 comment

Comments

@thawatchai
Copy link

Do you think it's workable to enable n+1 query tracking in production? Will it add much extra resource requirements to the production environment?

@doliveirakn
Copy link
Contributor

@thawatchai It is definitely workable. The gem uses ActiveSupport::Notifications to notify of N+1 queries. Just make sure whatever you have subscribed to the notification is also fast.

I've had code that looks something like this in production for years without issue:

ActiveSupport::Notifications.subscribe("n_plus_one_query") do |_event, data|
  Stats.increment("site.web.n_plus_one_queries.by_class", tags: ["class:#{data[:source].class.name}", "association:#{data[:association]}"])
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants