agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Voillequin, Jean-Marc <Jean-Marc.Voillequin@moodys.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>
Subject: Re: CTE materialized/not materialized
Date: Fri, 27 Nov 2020 10:35:02 -0500
Message-ID: <704895.1606491302@sss.pgh.pa.us> (raw)
In-Reply-To: <MW3PR20MB333805C074F3F28E972E0D6FBEF80@MW3PR20MB3338.namprd20.prod.outlook.com>
References: <MW3PR20MB3338A498F87D99C38C645006BEF90@MW3PR20MB3338.namprd20.prod.outlook.com>
	<20201127145347.GA17941@alvherre.pgsql>
	<MW3PR20MB333805C074F3F28E972E0D6FBEF80@MW3PR20MB3338.namprd20.prod.outlook.com>

"Voillequin, Jean-Marc" <Jean-Marc.Voillequin@moodys.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





view thread (6+ messages)  latest in thread

Message-ID: <704895.1606491302@sss.pgh.pa.us>
Permalink:  ../704895.1606491302@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/704895.1606491302@sss.pgh.pa.us

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Jean-Marc.Voillequin@moodys.com, alvherre@alvh.no-ip.org, pgsql-sql@lists.postgresql.org
  Subject: Re: CTE materialized/not materialized
  In-Reply-To: <704895.1606491302@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox