Repository navigation
Releases
Releases · alex00010/n1scan
v0.7.0
v0.6.1
Fixed
n1scan logsprints findings once, in the summary, instead of a live
stream followed by index suggestions bunched at the end.- The summary no longer says "0µs spent" when the log has no durations
(log_statement = 'all').
v0.6.0
Added
n1scan logs FILE...: finds N+1 queries in PostgreSQL server logs, for
staging and production where a proxy does not belong. Reads stderr (any
log_line_prefixwith a timestamp and%por%c), csvlog and jsonlog,
gzipped or not, from files or stdin; takes statements from
log_min_duration_statement = 0orlog_statement = 'all'and bind
parameters from the DETAIL line.--dband--userfilter,--dsnadds
index suggestions, and--ci,--baseline,--reportand query budgets
work as withrun. Multi-statement messages (psql -c "a; b") count as
several statements. Checked against the real logs of the 13-client matrix
in all three formats and with both settings (clients/logs-matrix.mjs,
clients/MATRIX-RESULTS-LOGS.md), plus a fuzz target for the parser.- MCP tool
n1scan_logs, and the skill tells agents when to use it. - The text summary of
n1scan logsshows the time the log covered; live
findings print the time of the burst instead of the time they were printed.
v0.5.0
Fixed
- GitHub Action: extra flags in
argsare no longer expanded as file names
by the shell (--ignore '.*'stayed a regexp only by luck). - With a baseline, the PR comment now shows exceeded query budgets; budget
results are printed before the footer in every Markdown report. - A burst hidden at its last checkpoint (for example parallel at 5
executions) is reconsidered when it closes, so a loop whose parent becomes
provable later is still reported. - A finding shown live that turns out to be parallel or pagination is now
withdrawn ("withdrawn": truein JSON, removed from the live screen)
instead of silently missing from the summary; the live screen labels
parallel and pagination findings. - Lineage candidates are found with one lookup per recent result instead of
one per column, which takes work off the shared lock on busy traffic. - Traced bursts recognise sibling loop bodies when guessing a parent.
n1scan mcpkeeps all reports of a server process in one directory.
Added
- ORM-aware fixes: each N+1 (and batchable write) comes with a fix; when the
SQL shows Prisma, Django, SQLAlchemy or Drizzle, the fix uses that ORM's
API (checked against real SQL from the client matrix), otherwise the
batched SQL form. One YAML pack per ORM ininternal/hints/rules. Shown in
the summary, JSON (fix), Markdown reports and the MCP tools. - Plugin icon and version, marketplace description and declared network
hosts:claude plugin validatepasses with no warnings. - A workflow runs n1scan's own Action on every pull request against the Go
example client, with a committed baseline and a sticky PR comment. - SECURITY.md: what n1scan promises and the trust model of
n1scan mcp;
private vulnerability reporting is enabled on the repository.
v0.4.1
Fixed
- Independent lookups spread over a connection pool could still be reported
as an N+1 when the client serialised them (a busy machine) or when the pool
opened its other connections late, so one connection ran almost all of
them. Without proven lineage, a burst on one connection is now independent
traffic when the same query ran on another connection during it (or just
before it), and both connections' bursts are marked. The eval and the
benchmark'sloadscenario are stable across repeated runs on a loaded
machine; a loop that awaits each query stays on one connection and is
still an N+1.
v0.4.0
For coding agents, and a demo anyone can run.
Added
n1scan mcp: a Model Context Protocol server over stdio with two tools,
n1scan_scan(run a command through n1scan; findings, proven parent,
report path) andn1scan_diff(compare two reports; verified or not).- Claude Code plugin and marketplace in
.claude-plugin/(skill + MCP
server):claude plugin marketplace add alex00010/n1scan, then
claude plugin install n1scan@n1scan. docs/demo-cli.gif, recorded from the realn1scan demooutput
(docs/demo/record_demo.py), andn1scan demo --color.
Changed
- When a client never asked for column names, lineage reads "came from its
1st column" instead of quoting a placeholder name. - README: agent section, demo GIF first, updated "How it works" and index
suggestion notes;bench/overheadexplains the 16-client cost with a
profile (forwarding without any analysis costs the same). - CONTRIBUTING: current layout,
eval/andpgfake.
v0.3.1
Added
n1scan demo: a small app with an N+1 against a simulated PostgreSQL
inside the binary, then the fix and the diff. Nothing to install.internal/pgfake, a minimal in-process PostgreSQL (startup, simple query
protocol) used by the demo and by proxy tests that now run without a
database, including on the Windows and macOS CI jobs.bench/overhead: pgbench numbers for v0.1.0 and v0.3.0 (1 and 16 clients,
simple, extended and prepared).
v0.3.0
Detector v2: n1scan proves which query a loop iterates over, and uses that
proof to stop guessing.
Added
- Lineage: n1scan hashes the first rows of every result and proves which
query a loop iterates over (parent proven: 20/20 values of $1 came from its column "id", in row order), also across the connections of a pool.
Reported aslineagein JSON and reports. - Kinds
parallel(independent overlapping requests with no parent) and
pagination(each value from the previous page), not N+1s; shown with
--all. - sqlcommenter and Rails query-log tags: findings carry
routeandsource
(file:line), and with a W3Ctraceparentrepetitions are grouped per
request instead of per connection. - Query budgets in
.n1scan.yaml(or--config):max_queries,
max_unique_queries,max_n1andmax_burst, for the whole run or per
route; reported in the summary and PR comment, enforced with--ci.
Unknown keys are rejected. - Index suggestions on PostgreSQL 12-15 for parameterised queries (
PREPARE
withplan_cache_mode = force_generic_plan, thenEXPLAIN EXECUTE), and
expression indexes forlower(col)/upper(col)filters. Suggestions
mention the extra write cost. eval/: 20 scenarios with a known answer, run in CI with a precision and
recall gate. Current: precision 1.00, recall 1.00.
Fixed
- Loops that pause between iterations (longer than
--gap) are detected
when each value keeps coming from the same parent column. - 60 independent lookups on a pool are no longer reported as an N+1.
v0.2.1
Fixed
- GitHub Action on macOS runners: the run step stopped before recording the
exit status (bash 3.2 rejects an empty array underset -u). CI now runs
the action on Windows and macOS too.
Changed
- Each statement is lexed once: the fingerprint pass also produces the
redacted text (about 1 µs and 14 allocations less per query).
v0.2.0
The CI gate release: adopt n1scan in a project that already has N+1 queries
and fail only on the ones a change adds.
Added
--report FILEwrites a versioned JSON document (n1scan/report/v1) or,
for.mdfiles, Markdown ready for a pull request comment. Findings have a
stableidderived from the normalised query.--baseline FILEcompares a run with an earlier report; with--cionly
findings that are not in the baseline fail.--update-baselinewrites it.
--fail-on new|worse|any,--fail-kindsand--allow-growthtune the gate.n1scan diff BASE HEAD(--format text|md|json) compares two reports and
refuses to call a result verified when the second run captured no queries,
the commands differ or the command failed (exit status 2).- GitHub Action (
uses: alex00010/n1scan@v0.2.0): downloads and checksums the
release binary on Linux, macOS and Windows runners, writes the job summary
and keeps one pull request comment up to date. skills/n1scan/SKILL.md: a before/after/diff protocol for coding agents.- New finding kind
batchablefor INSERT/UPDATE/DELETE once per row. It is
reported but does not fail--ciunless listed in--fail-kinds. n1scan help;bench/vs-sql-tapwith the benchmark script and results.- CI on Windows and macOS, a gofmt check, and a self-test of the action.
Changed
- Values are redacted by default everywhere: string, number and
dollar-quoted literals in SQL text, bound parameters and quoted parts of
server errors become?in the terminal, the live screen, JSON and reports.
--show-valuesshows them again. - With
--ci, a run in which no query went through the proxy now exits 2 and
says so, instead of printing "no N+1 patterns found". - Only
n+1findings fail--ciby default (write loops used to). - Fingerprint format 1 is now frozen and recorded in reports. It differs from
v0.1.0 in small ways:from (select,in (...)andvalues (...)keep
their space,-1and1share a shape, and= true/= falsebecome?.
Fixed
- A loop of slow statements (each longer than
--gap) was never reported,
because the burst was closed while the next statement was still running. - Lookups in separate tests that each end with
ROLLBACKwere merged into
one false N+1. - Unknown subcommands (
n1scan demo, typos) silently started the proxy; they
now print an error and exit 2.