Skip to content

Releases

v0.7.0

Choose a tag to compare

@github-actions github-actions released this 01 Dec 16:05

Changelog

  • d99b31a Merge pull request #25 from alex00010/p7/slow
  • 26287f4 Release v0.7.0
  • 185a2ed Slow queries: report shapes with an execution of --slow (100ms) or more

v0.6.1

Choose a tag to compare

@github-actions github-actions released this 01 Dec 12:35
a50b0d8

Fixed

  • n1scan logs prints 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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 12:24
15f832a

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_prefix with a timestamp and %p or %c), csvlog and jsonlog,
    gzipped or not, from files or stdin; takes statements from
    log_min_duration_statement = 0 or log_statement = 'all' and bind
    parameters from the DETAIL line. --db and --user filter, --dsn adds
    index suggestions, and --ci, --baseline, --report and query budgets
    work as with run. 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 logs shows the time the log covered; live
    findings print the time of the burst instead of the time they were printed.

v0.5.0

Choose a tag to compare

@github-actions github-actions released this 01 Dec 11:46

Fixed

  • GitHub Action: extra flags in args are 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": true in 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 mcp keeps 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 in internal/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 validate passes 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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 04:12
7d6907d

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's load scenario 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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 04:01
651773e

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) and n1scan_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 real n1scan demo output
    (docs/demo/record_demo.py), and n1scan 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/overhead explains the 16-client cost with a
    profile (forwarding without any analysis costs the same).
  • CONTRIBUTING: current layout, eval/ and pgfake.

v0.3.1

Choose a tag to compare

@github-actions github-actions released this 01 Dec 03:45
28925b2

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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 03:02
b78d392

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 as lineage in 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 route and source
    (file:line), and with a W3C traceparent repetitions are grouped per
    request instead of per connection.
  • Query budgets in .n1scan.yaml (or --config): max_queries,
    max_unique_queries, max_n1 and max_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
    with plan_cache_mode = force_generic_plan, then EXPLAIN EXECUTE), and
    expression indexes for lower(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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 02:04
11fc354

Fixed

  • GitHub Action on macOS runners: the run step stopped before recording the
    exit status (bash 3.2 rejects an empty array under set -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

Choose a tag to compare

@github-actions github-actions released this 01 Dec 01:10
454c308

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 FILE writes a versioned JSON document (n1scan/report/v1) or,
    for .md files, Markdown ready for a pull request comment. Findings have a
    stable id derived from the normalised query.
  • --baseline FILE compares a run with an earlier report; with --ci only
    findings that are not in the baseline fail. --update-baseline writes it.
    --fail-on new|worse|any, --fail-kinds and --allow-growth tune 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 batchable for INSERT/UPDATE/DELETE once per row. It is
    reported but does not fail --ci unless listed in --fail-kinds.
  • n1scan help; bench/vs-sql-tap with 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-values shows 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+1 findings fail --ci by 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 (...) and values (...) keep
    their space, -1 and 1 share a shape, and = true / = false become ?.

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 ROLLBACK were merged into
    one false N+1.
  • Unknown subcommands (n1scan demo, typos) silently started the proxy; they
    now print an error and exit 2.