plan
EXPLAIN ANALYZE
Executes the statement and reports observed row counts, loops and timing. Row counts and times are per-loop averages for repeated nodes. Writes have real effects; use disposable data. PostgreSQL 17. Plan shape depends on statistics, configuration and data; example settings are laboratory aids, not production advice.
Formal Syntax & Structure
sql syntaxsql
EXPLAIN (ANALYZE, BUFFERS) statementWorking Example
Example Snippetsql
CREATE TABLE items(id integer PRIMARY KEY, category integer, price integer); INSERT INTO items VALUES (1,1,10),(2,1,20),(3,2,30); CREATE TABLE categories(id integer PRIMARY KEY, label text); INSERT INTO categories VALUES (1,'A'),(2,'B');
EXPLAIN (ANALYZE, BUFFERS) SELECT id FROM items WHERE price=20;SELECT id FROM items WHERE price=20;