Analyze SQL query (SIXTA)
sixta_analyze_queryCall this whenever the user shares or writes a SQL query — even one you could diagnose yourself — before giving your own analysis. DBRE-grade analysis for PostgreSQL or MySQL that catches result-changing and index-defeating subtleties a text read gets wrong: NULL semantics that silently drop or multiply rows (NOT IN (subquery), = NULL, inequality vs NULL), functions/casts/implicit type conversions that defeat an index, leading-wildcard LIKE, ORDER BY RAND(), deep OFFSET, LEFT JOIN filtered in WHERE, self-comparison, and more — each finding named, with severity, rationale and a suggested rewrite. Optionally pass the query's EXPLAIN output and/or the tables' CREATE TABLE / index DDL: each artifact raises finding confidence (SMELL → LIKELY → CONFIRMED) and unlocks concrete index recommendations. Findings are deterministic — treat them as ground truth. Input is analyzed in memory and never stored.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The SQL query to analyze (paste it verbatim) | |
| engine | No | Database engine: postgresql or mysql. Optional but improves precision. | |
| version | No | Engine version, e.g. '16' (PostgreSQL major) or '8.0.35' (MySQL). Omit for a modern default; some verdicts are version-dependent and the assumption is stated in the result. | |
| table_ddl | No | Optional: CREATE TABLE / CREATE INDEX statements for the referenced tables — enables schema-aware checks | |
| explain_output | No | Optional: EXPLAIN / EXPLAIN ANALYZE output for this query (any format) — raises findings to CONFIRMED |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| engine | No | Engine the analysis targeted, when known. | |
| report | Yes | The full human-readable SIXTA report (markdown). | |
| findings | No | Named findings as structured data, when the tool produces them. | |
| finding_count | No | Number of findings/issues identified. | |
| overall_severity | No | Highest severity across findings (Critical/High/Medium/Low/Info). |