Skip to main content

Query Analyze

Query Analyze is a static SQL rewrite advisor that runs entirely in your browser. Paste a SQL query and click "Query Analyze" to get rewrite suggestions and query-shape warnings. No database connection is needed and the query is never executed.

How it works​

  1. SQL text is normalized so comments and literals do not create obvious false positives.
  2. A set of client-side checks looks for common rewrite opportunities and correctness risks.
  3. Findings are labeled by severity and confidence so you can decide what deserves validation.

Severity and confidence​

Each finding has a severity and confidence level:

  • HIGH confidence — safe to act on in most cases.
  • MED confidence — usually correct but verify against your specific query.
  • LOW confidence — heuristic suggestion; treat as a starting point, not a verdict.

Finding categories​

Query Analyze currently runs 25 rules covering a range of anti-patterns. The advisor checks for:

  • predicates that hide useful indexes (function-wrapped columns, leading wildcards, unanchored regex)
  • NULL-sensitive anti-join patterns (NOT IN without NOT NULL guard)
  • pagination and ordering mistakes (large OFFSET, missing ORDER BY on LIMIT)
  • joins that imply accidental row multiplication (correlated subqueries, redundant joins)
  • existence checks that count more than necessary (COUNT(*) without LIMIT, subquery in SELECT)
  • timestamp boundary patterns (implicit timezone conversion, date casts)
  • broad scans caused by wildcard or negative predicates (LIKE '%x', NOT IN)
  • repeated subqueries and readability issues
  • cases where a rewrite should be validated with EXPLAIN before applying

The rules are numbered and carry severity (HIGH/WARN/INFO) and confidence (HIGH/MED/LOW). The exact patterns and internal thresholds are intentionally not published in detail — they may change as the product logic improves.

Design principles​

  • Rewrite-first — the advisor focuses on SQL shape before suggesting schema changes.
  • Hedged wording — messages say "often", "may", "typically". No absolute claims about planner behavior.
  • Validate with EXPLAIN — static analysis is a starting point, not a substitute for measuring the original and rewritten query.