SQL Complexity Analyser
Paste a query to measure its complexity: joins, CTEs, subquery depth, window functions, and predicates, with a score and specific hotspots to simplify or check for performance.
How the complexity score works
The analyser reads your SQL locally and counts the structures that make queries harder to read, review, and optimise. Each adds to a score from 0 to 100:
- Joins, with extra weight for
CROSS JOINandFULL OUTER JOIN. - Subqueries and nesting depth: deeply nested
SELECTs are hard to follow and often hide repeated work. - CTEs, window functions,
CASEexpressions,UNIONs, andDISTINCT. - Predicates: the number of
ANDandORconditions, with extra weight forOR, which often prevents index use.
Scores under 25 are low, 25 to 59 moderate, and 60 or more high.
Hotspots
Beyond the score, the analyser flags patterns that commonly cause slow or fragile queries: SELECT *, functions wrapped around columns in WHERE (which stop the database from using an index), leading-wildcard LIKE '%…', NOT IN with a subquery (surprising with NULLs), ORDER BY without LIMIT, implicit comma joins, and UNION where UNION ALL would do. These are prompts to check, not guaranteed problems; confirm with your database's EXPLAIN plan.
Frequently asked questions
Does this run my query?
No. The analyser only reads the SQL text in your browser. It never connects to a database or uploads the query.
Is a high score always bad?
No. Reporting queries are often legitimately complex. Use the score to spot queries worth breaking into CTEs, views, or dbt models, and use EXPLAIN to judge real performance.
Which dialects does it support?
It works on the SQL text itself, so it handles PostgreSQL, MySQL, SQL Server, BigQuery, Snowflake, Spark and most other dialects. Quoted identifiers, strings, and comments are ignored when counting.