plan
Partition pruning
Eliminates partitions whose bounds cannot satisfy predicates, during planning or eligible execution phases. It is a planning/execution technique, not a named plan node. PostgreSQL 17. Plan shape depends on statistics, configuration and data; example settings are laboratory aids, not production advice.
Formal Syntax & Structure
sql syntaxsql
EXPLAIN SELECT ... FROM partitioned_table WHERE partition_key = valueWorking 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');CREATE TABLE events(id integer) PARTITION BY RANGE(id); CREATE TABLE events_low PARTITION OF events FOR VALUES FROM (0) TO (10); CREATE TABLE events_high PARTITION OF events FOR VALUES FROM (10) TO (20); INSERT INTO events VALUES (1),(11);EXPLAIN (FORMAT JSON) SELECT id FROM events WHERE id=11;SELECT id FROM events WHERE id=11;