plan
Hash join
Builds a hash table from one input and probes it with the other for hashable equality joins. Memory pressure can lead to multiple batches. 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 a JOIN b ON a.key=b.keyWorking 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');SET enable_nestloop=off; SET enable_mergejoin=off;EXPLAIN (FORMAT JSON) SELECT i.id,c.label FROM items i JOIN categories c ON c.id=i.category ORDER BY i.id;SELECT i.id,c.label FROM items i JOIN categories c ON c.id=i.category ORDER BY i.id;