Skip to content

Add query counts and maximum queries to log configuration#74

Open
emilong wants to merge 3 commits intocharkost:mainfrom
binti-family:query-counts
Open

Add query counts and maximum queries to log configuration#74
emilong wants to merge 3 commits intocharkost:mainfrom
binti-family:query-counts

Conversation

@emilong
Copy link
Copy Markdown

@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
Copy Markdown

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

@jlinarez1
Copy link
Copy Markdown

How can I help this to merge?

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.

4 participants