agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Voillequin, Jean-Marc <Jean-Marc.Voillequin@moodys.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@lists.postgresql.org <pgsql-sql@lists.postgresql.org>
Subject: Re: CTE materialized/not materialized
Date: Fri, 27 Nov 2020 14:03:03 -0300
Message-ID: <20201127170303.GA14088@alvherre.pgsql> (raw)
In-Reply-To: <MW3PR20MB33388940243849D8EA2881C3BEF80@MW3PR20MB3338.namprd20.prod.outlook.com>

On 2020-Nov-27, Voillequin, Jean-Marc wrote:

> Thank you Tom & Alvaro.
> I'm still dreaming of such query planner!

An idea mentioned several times is that of making more expensive
optimizer passes for certain plans -- either at the user's request or
merely based on the initial estimated cost being very large.  A query
that's seems more expensive to execute would also seem to warrant a
greater optimization effort.  (But if it's automated and we get it
wrong, then we'd get complaints that we spend pointless time in the
optimizer.)

Your sample plan has 3 CTEs, so we would have to plan eight queries for
the brute-force way -- one per combination of each CTE inlined or
materialized.  Maybe it's worth the optimizer cost, maybe not.  Now
maybe there's a smarter approach than brute-forcing it.





view thread (6+ messages)

Message-ID: <20201127170303.GA14088@alvherre.pgsql>
Permalink:  ../20201127170303.GA14088@alvherre.pgsql/
Also on:    postgresql.org/message-id/20201127170303.GA14088@alvherre.pgsql

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: alvherre@alvh.no-ip.org, Jean-Marc.Voillequin@moodys.com, tgl@sss.pgh.pa.us, pgsql-sql@lists.postgresql.org
  Subject: Re: CTE materialized/not materialized
  In-Reply-To: <20201127170303.GA14088@alvherre.pgsql>

* 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