Use EXPLAIN to inspect a query plan without executing it:
EXPLAIN
SELECT category, count(*)
FROM events
GROUP BY category;Supported plan formats:
EXPLAIN (FORMAT TEXT) SELECT * FROM events;
EXPLAIN (FORMAT GRAPHVIZ) SELECT * FROM events;The alternate utility syntax is also accepted:
EXPLAIN FORMAT GRAPHVIZ SELECT * FROM events;Use EXPLAIN ANALYZE to execute the query and print an execution report:
EXPLAIN ANALYZE
SELECT category, count(*)
FROM events
GROUP BY category;EXPLAIN ANALYZE currently supports text output.
Unsupported options include VERBOSE, QUERY PLAN, ESTIMATE, and
non-text EXPLAIN ANALYZE formats.
In the REPL
EXPLAIN and EXPLAIN ANALYZE are SQL statements, so they must end with ;:
EXPLAIN SELECT 1;Last updated on