n1scan: a local Postgres proxy that flags N+1 queries in any app or ORM

N+1 query bugs often escape slow-query logs because each individual query runs quickly, while the loop that issues them slows an endpoint badly. Existing detectors such as Bullet, nplusone, and debug toolbars are tied to specific frameworks and run inside the application process. The author built n1scan, an open-source Go tool that runs as a local proxy between an app and PostgreSQL and reports repeated query shapes with differing values, requiring no code changes. It fingerprints queries, identifies the statement that precedes a burst as the likely parent, and suggests indexes when it detects sequential scans on large tables. The tool is MIT licensed, supports a range of clients and ORMs, and includes a CI mode that returns a failing exit code when an N+1 is detected.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in