I asked PostgreSQL to explain my query. Part of the explanation was:
table_name --> Materialize
What does materialize do? I\'m joining t
In merge join and nested loop join, the database will "rescan" the inner loop. Basically like:
for each row in outer table:
for each row in inner table:
# do something
The planner will materializes the inner loop table which means load the whole table in an in-memory buffer to avoid the expensive disk IO cost.
A useful link.