dryrun

v0.24.0
io.github.boringSQL/dryrun Checked 18 minutes ago Published 9 days ago

PostgreSQL schema intelligence from a committed snapshot.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

advise

One-shot review of a single query: validation and index suggestions from the snapshot, plus plan-shape advice and plan warnings when you pass plan_json -- a plan the user pasted or CI captured. Needs no database connection and executes nothing; without plan_json there is simply no plan to read. It returns corrected_sql when every unknown name has one obvious candidate; it never rewrites the query for performance.

ParameterTypeDescription
sql *stringSQL query.
include_index_suggestionsbooleanInclude index suggestions (default true).
plan_jsonobject | array | stringAn EXPLAIN plan you already have, pasted by the user or captured in CI: the [{"Plan": ...}] array EXPLAIN (FORMAT JSON) returns, or the unwrapped {"Plan": ...} object. A JSON string of either is accep…

check_migration

Before any ALTER TABLE, CREATE INDEX, DROP, or other DDL reaches a database: the lock level each statement takes, whether it rewrites the table, and rollback_ddl where one applies. Tables created earlier in the same input are recognized as empty, so statements against them are not flagged for scans or rewrites they cannot cause. Where the safe form is mechanical it returns safer_sql -- the rewrite as statements to run in order, each on its own rather than wrapped in one transaction. When at least one statement is unsafe and every unsafe statement has one, migration_sql bundles the whole input…

ParameterTypeDescription
ddl *stringDDL statement, or a whole goose/dbmate/tern migration file.
directionstringWhich half of a migration file to check: 'up' (default) or 'down'. Plain SQL has no down section, so direction='down' errors there.

describe_table

Before writing SQL against a table you have not read in this session, before a JOIN, or before a DELETE that might cascade: one table in full -- its columns and types, constraints, indexes, and planner stats. Needs no database connection; answers from the snapshot, and points at detect when the table has findings. detail=relations gives the incoming and outgoing foreign keys, each with a JOIN clause you can paste and the ON DELETE / ON UPDATE action it carries (declared constraints only, one hop, so a table reached by a cascade may cascade further). detail=stats adds vacuum: dead tuples, trigg…

ParameterTypeDescription
table *stringTable name, bare or schema-qualified.
columnsarrayOnly these columns, by exact name. The way to read four columns of a wide table.
detailstringDetail level: 'summary' (default), 'full' (raw stats), 'stats' (profiles, stats and vacuum only), 'relations' (foreign keys on both sides, no columns).
fieldsarrayWhitelist of sections: columns, indexes, constraints, stats, partition_info, column_profiles, comment, policies, triggers, reloptions, rls_enabled, ddl, vacuum, relations, dependents. Ask for ddl to g…
limitnumberMax columns, indexes, constraints, partition children, relations per direction and dependents (default 50, 0 for all). Key, unique and indexed columns are kept past it, as are relations that cascade o…
schemastringSchema name. Without it a bare name resolves in public, or in the one schema that holds it.

detect

When a query got slow, before a tuning change, when autovacuum or dead tuples come up, or when asked what is wrong with this database: stale statistics, unused indexes, bloated indexes and tables, per-table scan anomalies, and vacuum health. kind=vacuum_health reports autovacuum_disabled, default_knobs_large_table, high_dead_tuple_ratio, vacuum_threshold_too_high, freeze_age_high and mxid_age_high, each with the dead-tuple counts and last (auto)vacuum and analyze times behind it. Every kind reports offenders only: a table with nothing wrong does not appear, here or in kind=all. For a table wit…

ParameterTypeDescription
kindstringWhich detection to run (default: all).
limitnumberMax entries per category (default 50, 0 = all; a response over 1 MiB is refused, so page with offset instead).
offsetnumberSkip N entries of each list; for a single kind only (kind=all pages through the _meta.next calls it emits).
schemastringSchema filter; omit for all schemas.
tablestringTable filter, bare or schema-qualified.
thresholdnumberBloat ratio threshold; applies to kind=bloated_indexes, kind=bloated_tables and kind=all.

find_objects

First call against an unfamiliar database, and the way to find where a name lives. With no query it inventories what exists and how big it is in production -- row estimates and table size (the heap: indexes and TOAST are not counted), partition children folded into their parent -- which the repo cannot tell you; kind= inventories views, functions or enums instead. With a query it searches names, table and column comments, index and view definitions, and enum labels, so a value like 'cancelled' finds the enum that carries it, not just an object named after it. Every hit is tagged with the field…

ParameterTypeDescription
kindstringRestrict to one kind. Default: tables when there is no query, every kind when there is one.
limitnumberMax results (default 50, 0 = all; a response over 1 MiB is refused, so page with offset instead). Truncation sets _meta.next to the next page (offset).
offsetnumberSkip N results.
querystringCase-insensitive substring. Omit to inventory rather than search.
schemastringSchema filter; omit for all schemas.
sortstringOrder: 'name', or 'rows'/'size' biggest first (objects that have no table sort last). Default is name without a query, match quality with one.

lint_schema

When reviewing a schema as a whole -- a design review, an inherited database, or the state a migration left behind: naming and convention violations plus an audit of missing keys, unindexed foreign keys, and unsafe defaults. Needs no database connection. Defaults to verbosity='summary', which returns per-rule counts only: pass verbosity='full' for the findings and their ddl_fix (not every finding has one). Whole-schema, not per-query (validate_query, advise); it applies nothing.

ParameterTypeDescription
fieldsarrayWhitelist of sections: conventions, audit. Overrides 'scope' when set.
schemastringSchema filter; omit for all schemas.
scopestringScope: 'conventions', 'audit', or 'all' (default).
tablestringTable filter, bare or schema-qualified.
verbositystringVerbosity: 'summary' (counts and rule names) or 'full' (findings, examples, ddl_fix).

list_top_queries

When asked what this database spends its time on: captured pg_stat_statements query shapes ranked by exec time, calls, or mean. Needs no database connection; reads the local history (dryrun snapshot capture --streams query, or init's best-effort capture) and is empty when no capture carries query stats. Each entry is tagged with its reporting node and never averaged across nodes: a primary and a replica are different workloads. A node label that rotates between servers reports only the server that answered its newest capture; _meta.hint says so when the captures show it. SQL is qshape-normaliz…

ParameterTypeDescription
limitnumberMax results (default 50, 0 = all; a response over 1 MiB is refused, so page with offset instead).
min_callsnumberSkip entries with fewer calls than this (default 2) to filter one-shot noise.
nodestringFilter to one node label. Omit to see all nodes' queries together (each entry still tagged with its own node).
offsetnumberSkip N results; a truncated result sets _meta.next to the next page. Ranking is of the newest capture per node, so a capture landing between pages can shift it.
sortstringSort by: 'total_time' (default, total_exec_time_ms), 'calls', or 'mean_time' (mean_exec_time_ms).

snapshot_diff

When something changed and you need to know what: the schema DDL delta between two snapshots, plus planner sizing, activity, and query-shape drift correlated to the same capture window. Needs no database connection, but does need two snapshots in the local history. Snapshot-to-snapshot only, never against the live database (check_drift); it reports what moved, not why. Totals are a delta over the interval between the two anchors, not a rate: capture cadence is irregular, so deltas over unequal intervals do not compare. Each per-node query delta reports that interval as `window` in nanoseconds…

ParameterTypeDescription
fromstringBase snapshot: 'latest~N' or a content-hash prefix. Default 'latest~1'. latest~N counts captures, not changes: a node captured while unchanged stores an identical snapshot, so an empty delta can mean…
kindstringTimeline the refs name and the headline delta; the other kinds are correlated by capture time. Use 'planner' when the schema is stable but stats/sizing moved, 'query' for pg_stat_statements drift (per…
limitnumberMax objects (and moved raw rows in full view); 0 = as many as fit in one response (~64 KB of JSON text). A cut page reports truncated_by (limit|bytes) and limit_applied; _meta.next holds the call for…
nodestringActivity node label, when activity has multiple nodes.
offsetnumberSkip the first N objects (and, in full view, N rows of each raw list), to page past a truncated result. The summary view's plan_shifts are not paged.
schemastringNarrow to one schema.
tablestringNarrow to one table. Bare names only: unlike detect and lint_schema this filter runs against the snapshots being compared, not the loaded one.
tostringTarget snapshot: 'latest' or a content-hash prefix. Default 'latest'.
viewstring'summary' (ranked objects + counts) or 'full' (adds the raw per-row deltas; query shapes that did not move are left out and counted in flat_entries, and canonical SQL is cut at 300 bytes ending in ' 
window_minutesnumberCorrelation window for matching planner/activity captures to each anchor (default 30).

validate_query

Before proposing or running any SQL: checks it against the snapshot and reports unknown tables, unknown columns on qualified references (t.col), and anti-patterns. When every unknown name has exactly one candidate it also returns corrected_sql -- the same query with those names replaced, re-validated -- so a misspelling comes back as a patch rather than prose. Needs no database connection and never executes the query. Names and shape only: not cost, not plan, not whether any rows match (advise, explain_query).

ParameterTypeDescription
sql *stringSQL query.