pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Joel Jacobson <joel@compiler.org>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Planning time grows exponentially with levels of nested views
Date: Tue, 06 Jul 2021 13:52:10 -0400
Message-ID: <1716811.1625593930@sss.pgh.pa.us> (raw)
In-Reply-To: <CAEZATCW+G7aeRH+GaV5ZJNkhyZetpF_XeAZdSZwTY-9W1_+Egw@mail.gmail.com>
References: <797aff54-b49b-4914-9ff9-aa42564a4d7d@www.fastmail.com>
	<140747.1618776847@sss.pgh.pa.us>
	<141461.1618778513@sss.pgh.pa.us>
	<CAEZATCW+G7aeRH+GaV5ZJNkhyZetpF_XeAZdSZwTY-9W1_+Egw@mail.gmail.com>

Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> I took a look at this and wasn't able to find any way to break it, and
> your argument that it can't really make such rewriter bugs any worse
> makes sense.

Thanks for looking!

> Would it make sense to update the comment prior to copying the subquery?

Yeah, I hadn't touched that yet because the question was exactly about
whether it's correct or not.  I think we can shorten it to

     * Need a modifiable copy of the subquery to hack on, so that the
     * RTE can be left unchanged in case we decide below that we can't
     * pull it up after all.

> Out of curiosity, I also tested DML against these deeply nested views
> to see how the pull-up code in the rewriter compares in terms of
> performance, since it does a very similar job. As expected, it's
> O(N^2) as well, but it's about an order of magnitude faster:

Oh good.  I hadn't thought to look at that angle of things.

> ... for a one-line change, that's pretty impressive.

Yeah.  The problem might get less bad if we get anywhere with the
idea I suggested at [1].  If we can reduce the number of RTEs
in a view's query, then copying it would get cheaper.  Still,
not copying it at all is always going to be better.  I'll go
ahead and push the patch.

			regards, tom lane

[1] https://www.postgresql.org/message-id/697679.1625154303%40sss.pgh.pa.us





view thread (6+ messages)

Message-ID: <1716811.1625593930@sss.pgh.pa.us>
Permalink:  ../1716811.1625593930@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1716811.1625593930@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dean.a.rasheed@gmail.com, joel@compiler.org, pgsql-hackers@lists.postgresql.org
  Subject: Re: Planning time grows exponentially with levels of nested views
  In-Reply-To: <1716811.1625593930@sss.pgh.pa.us>
  References: <797aff54-b49b-4914-9ff9-aa42564a4d7d@www.fastmail.com> <140747.1618776847@sss.pgh.pa.us> <141461.1618778513@sss.pgh.pa.us> <CAEZATCW+G7aeRH+GaV5ZJNkhyZetpF_XeAZdSZwTY-9W1_+Egw@mail.gmail.com> <1716811.1625593930@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox