What Makes a Good SQL Query?
Writing SQL is easy. Writing good SQL is an art. Whether you’re pulling Statcast data from Baseball Savant or joining complex fact tables in a warehouse, the quality of your query matters — for performance, readability, and maintainability.
This tool scores your SQL query across five dimensions:
| Dimension | What it checks |
|---|---|
| Readability | Formatting, keyword casing, alias clarity |
| Efficiency | Avoids SELECT *, unnecessary subqueries |
| Best Practices | Uses CTEs, avoids old-style joins |
| Complexity | Appropriate use of window functions, aggregations |
| Safety | No unfiltered full-table scans, proper WHERE clauses |
Paste your query below and get an instant score out of 100.
How the Scoring Works
The scorer runs entirely in your browser — no query is sent to any server.
Readability (20 pts) checks whether your SQL keywords are uppercased, clauses are indented, aliases use AS, and the query is split across multiple lines.
Efficiency (20 pts) penalizes SELECT *, bare subqueries in FROM clauses (when a CTE would be cleaner), and queries with no filtering or aggregation.
Best Practices (25 pts) rewards CTEs over nested subqueries, explicit JOIN syntax over old-style comma joins, and qualifying column names with a table alias.
Complexity (20 pts) gives credit for appropriate use of window functions, aggregations with GROUP BY, and CASE WHEN logic.
Safety (15 pts) flags queries without a WHERE clause and warns about destructive operations like DELETE, DROP, or UPDATE.
Note: This scorer uses static heuristics — it’s a learning tool, not a query planner. It can’t evaluate index usage, cardinality estimates, or dialect-specific optimizations. For that, run
EXPLAIN ANALYZEin your database.