Re: CTE materialized/not materialized

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, "pgsql-sql(at)lists(dot)postgresql(dot)org" <pgsql-sql(at)lists(dot)postgresql(dot)org>
Subject: Re: CTE materialized/not materialized
Date: 2020-11-27 15:35:02
Message-ID: 704895.1606491302@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Voillequin, Jean-Marc" <Jean-Marc(dot)Voillequin(at)moodys(dot)com> writes:
> Let me rephrase.
> In the case the CTE can be inlined, why PG does not compute 2 plans (P1 with CTE inlined, P2 with CTE materialized) and compare them to choose the best?

It would be excessively expensive (even for just one CTE, never mind
several) and it wouldn't fit into the planner's structure very well.
As noted in the comment Alvaro quoted, the point where we make these
decisions is pretty far upstream of having any concrete cost estimates.

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Voillequin, Jean-Marc 2020-11-27 15:58:02 RE: CTE materialized/not materialized
Previous Message Voillequin, Jean-Marc 2020-11-27 15:18:31 RE: CTE materialized/not materialized