EXPLAIN

An SQL command for showing the execution plan of a statement

EXPLAIN is a utility command for showing the execution plan of a statement.

EXPLAIN has always been present in PostgreSQL.

Usage

EXPLAIN can be used to show the execution plan of one of the following statement types:

Change history

Examples

Minimal usage example for EXPLAIN:

postgres=# EXPLAIN SELECT * FROM bar;
                      QUERY PLAN
-------------------------------------------------------
 Seq Scan on bar  (cost=0.00..35.50 rows=2550 width=4)
(1 row)

Attempting to execute EXPLAIN with a query type which does not support it:

postgres=# EXPLAIN COPY bar FROM STDIN;
ERROR:  syntax error at or near "COPY"
LINE 1: EXPLAIN COPY bar FROM STDIN;

Categories

Planner, Utility command