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

Add query counts and maximum queries to log configuration #74

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

emilong
Copy link

@emilong emilong commented Nov 9, 2023

While using prosopite on an application with many N+1s, I wanted to focus my efforts on the N+1s with the most associated queries, so I added a count of queries.

I also found that I really only needed one query per N+1 to debug each issue, so I added a configuration to limit the number of queries logged.

The result looks something like this:

W, [2023-11-09T17:48:23.795072 #338497]  WARN -- : N+1 queries detected (20):
  SELECT "legs".* FROM "legs" WHERE "legs"."chair_id" = ? ORDER BY "legs"."id" ASC LIMIT ?
Call stack:

with this configuration:

Prosopite.display_query_count = true
Prosopite.display_max_n_queries = 1

I decided to make them both optional in case anyone depends on the existing format.

@juliolinarez
Copy link

Awesome idea! In fact, this should be a default configuration

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

Successfully merging this pull request may close these issues.

3 participants