SQL explain plan: what is Materialize?

后端 未结 5 614
轮回少年
轮回少年 2020-12-25 11:07

I asked PostgreSQL to explain my query. Part of the explanation was:

table_name --> Materialize

What does materialize do? I\'m joining t

5条回答
  •  温柔的废话
    2020-12-25 11:27

    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.

提交回复
热议问题