PostgreSQL の、プランナーにおける Materialize ノードについて

Published: 2022/4/9


EXPLAIN などをした時に、プランナーにより表示される実行ノードのうち、 Materialize ノードがどのようにふるまうかについてのメモ。

https://www.postgresql.org/docs/current/using-explain.html

上記ページより抜粋して、

Notice that here the planner has chosen to "materialize" the inner relation of the join, by putting a Materialize plan node atop it. This means that the t2 index scan will be done just once, even though the nested-loop join node needs to read that data ten times, once for each row from the outer relation. The Materialize node saves the data in memory as it's read, and then returns the data from memory on each subsequent pass.

であるので、 Materialize ノードは、取得したレコードをメモリ上に補完しておき、それをループごとに再利用することができるノードであることが読み取れる。 また、

によれば、 materizalize におけるデータは、レコードのタプルがそのままメモリに配列みたいな形で保管されていることが、ソースコードから読み取れる、とのこと。


Tags: postgresql

関連記事