SQL explain plan: what is Materialize?

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

    We can say the Materialize command will create a View of a table(just like a virtual table OR a SnapShot of table in Memory)

    It is used to enhance visibility of the data by presenting it in a more informational context and to control access to the data by hiding critical or sensitive data from users who don't need to see it/or to whom we don't what to show it.

    The main benefit of using Materialize/Snap-Shot is to reduce the cost of query on that table afterwards. In execution plan the same states that how much benefit we may fetch if we use materialize compare to when it is not used!

    Explain to check execution plan

    ->  Materialize  (cost=0.29..8.51 rows=10 width=244)
             ->  Index Scan using tenk2_unique2 on tenk2 t2  (cost=0.29..8.46 rows=10 width=244)
                   Index Cond: (unique2 < 10)
    

    I have ignored this --> as there is not such operator in my knowledge, plus the -- will comment the expression afterwards, I have assumed you meant this -> only.

    I hope this helps..

提交回复
热议问题