SQL explain plan: what is Materialize?

后端 未结 5 612
轮回少年
轮回少年 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:41

    A materialize node means the output of whatever is below it in the tree (which can be a scan, or a full set of joins or something like that) is materalized into memory before the upper node is executed. This is usually done when the outer node needs a source that it can re-scan for some reason or other.

    So in your case, the planner is determining that the result of a scan on one of your tables will fit in memory, and it till make it possible to choose an upper join operation that requires rescans while still being cheaper.

提交回复
热议问题