Command
Explain Query
Explains what a SQL query returns, how the database plans to run it and which parts will be slow, using the real plan if allowed.
11. Identify the dialect and find the schema and indexes for each table involved. If the query is in application code, extract the SQL and note the bound parameters.
22. Say in two sentences what the query returns and for whom. Then walk through it in logical order: FROM and joins, WHERE, GROUP BY, HAVING, window functions, ORDER BY, LIMIT. One line each.
33. Predict the physical plan: which index each filter could use, join method and order, and where a sort or temp table is needed.
44. Offer to run `EXPLAIN` (never `EXPLAIN ANALYZE` on writes, since it executes them). Run it only when a read-only connection is available and the user agrees.
55. Flag slow spots: functions on indexed columns, leading wildcard LIKE, SELECT *, OR across columns, correlated subqueries, missing join indexes, OFFSET paging.
Claude CodeCodex
Explain Query
CommandDatabases
Free