Plan nodes · Joins
Materialize
Stores its input in memory so it can be read again.
Reads its child once and keeps the rows, usually so that a Nested Loop can rescan the inner side without recomputing it. Spills to disk past work_mem.
Example
SELECT a.name, p.name FROM artists a, playlists p WHERE a.id < 4 AND p.id < 300
4 nodes
- Nested Looprows 897 (estimated 897) cost 0.28..29.8 buffers: 7 hit
- Seq Scan on playlists prows 299 (estimated 299) cost 0..10.25 buffers: 4 hitfilter
(id < 300)201 removed by the filter - Materializerows 3 × 299 loops (estimated 3) cost 0.28..8.35 buffers: 3 hit
- Index Scan using artists_pkey on artists arows 3 (estimated 3) cost 0.28..8.33 buffers: 3 hitindex condition
(id < 4)1 index searches
Run with EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) on the sample database, PostgreSQL 19.0. Open it in the EXPLAIN visualizer →
Related
Nested Loop · Hash Join · Hash · Merge Join · Memoize