Analyze SQL safety & cost
analyze_sqlAnalyze Postgres SQL/migrations for destructive operations, locking risk, correctness traps (NULL handling that silently returns wrong results), anti-patterns, and query cost. Returns a deterministic verdict (ok/warn/block) with findings. Pass the optional schema argument (your CREATE TABLE/INDEX DDL) to also get EXPLAIN-based cost analysis run on a throwaway scratch Postgres — no separate tool or DB connection needed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL to analyze (one or more statements). | |
| schema | No | Optional CREATE TABLE/INDEX DDL. Providing it enables EXPLAIN-based cost analysis (seq scans on large tables, etc.) on a throwaway scratch Postgres; omit it for static safety analysis only. | |
| dialect | No | ||
| rowCountHints | No | Optional map of table name to estimated row count for realistic cost estimates. |