SQL Query Explanation
Query: $ARGUMENTS
- If a file path was given, read the file. If a query was pasted, use it directly.
- Plain English explanation:
- What tables are involved?
- What data is being filtered/joined?
- What is the final result set?
- Walk through execution order (FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER → LIMIT)
- Potential issues:
- Missing indexes on WHERE/JOIN columns
- Cartesian products (missing JOIN condition)
SELECT *when specific columns would do- Subqueries that could be CTEs or JOINs
- Functions on indexed columns preventing index use (
WHERE LOWER(email) = ...)
- Optimization suggestions (with rewritten query):
- Indexes to add (with
CREATE INDEXstatement) - Query rewrite if applicable
- For Postgres/MySQL: suggest running
EXPLAIN ANALYZE
- Estimate complexity: O(n), O(n log n), O(n²) roughly.