Skip to content

What counts as an N+1 query?

By default SQLEye flags an N+1 when the same query shape runs at least 5 times on the same connection within 1,000 ms, with differing literal values. A loop that fires one SELECT per row is the classic case. The thresholds are settings, so you can change both the repeat count and the time window.

Repeating the identical statement with identical values is not flagged. Transaction and session statements such as BEGIN, COMMIT, SET and SHOW are never counted. Statements with unbound placeholders such as $1 or ? count as differing. A gap longer than the window ends a run.

When SQLEye detects a group, the Live screen collapses it into one expandable row showing the repeat count. Read N+1 detection for the rule in full, and the glossary entry on the N+1 query for background.

← All questions · This page is also available as Markdown.

SQLEye is developed and maintained by CodeROG. This page is also available as Markdown.