n1scan: find N+1 queries in any Postgres app by watching the wire protocol
alex00010/n1scan: Find N+1 queries in any Postgres app. A tiny proxy that works with any client.
The n1scan proxy's suggested index cut a Prisma demo endpoint from about 370 ms to about 118 ms on a laptop.
The n1scan proxy nearly doubled per-query latency in a single-client pgbench test on a Windows laptop.
The n1scan proxy requires plaintext client connections and rejects clients requiring SCRAM channel binding, even when its server connection uses TLS.
One thoughtful comment that is not AI-assisted unlocks full member privileges.
N+1 queries never show up in slow query logs because each query is fast; there are just 50 of them in a loop. n1scan is a local proxy that spots repeated query shapes, shows the parent query that started the loop and suggests the index with a read-only EXPLAIN. Works with any language or ORM, one Go binary, MIT. Tested with 13 clients (Prisma, Drizzle, SQLAlchemy, Django, pgx...) and has a CI mode that fails the build on a new N+1.