On this page
EXPLAIN SELECT * FROM users WHERE id = 5;
EXPLAIN (ANALYZE, FORMAT JSON) SELECT * FROM orders WHERE user_id = 5;
EXPLAIN ANALYZE SELECT u.name, count(*) FROM users u JOIN orders o ON o.user_id = u.id GROUP BY
u.name;Output shapes (implemented in crates/executor/src/query/explain.rs)#
Seq Scan on T (cost=1.01..1.01 rows=N width=W) [(filter: WHERE)]- Joins:
Seq Scan on A JOIN B;UNION → Append [ALL];INTERSECT → Hash Intersect [ALL];EXCEPT → Hash Except [ALL];WITH → CTE Scan (N CTEs); writes:Insert|Update|Delete on T. EXPLAIN ANALYZEexecutes the inner statement and appendsActual Rows: N, Execution Time: 0.00ms.FORMAT JSONreturns one JSON doc withPlan{Node Type, Relation, Startup/Total Cost, Plan Rows/Width}plus actuals when analyze.
What to look for#
- Relation + filter: is the predicate where you expect?
Actual Rowsvs estimatedrows: large gaps mean the shape assumption is off.- v0.1.0 has no cost-based planner (
crates/optimizeris a stub) —EXPLAINdescribes scan/join/set shapes, not an index-choice trace. Measure withEXPLAIN ANALYZEand Performance.
Constraints#
EXPLAIN accepts (ANALYZE, FORMAT json|text, COSTS|BUFFERS|…) options; unknown options are tolerated in the option list but only analyze/format change output.
Was this page helpful? Thanks — noted locally, nothing is sent anywhere.