Re: Planning time grows exponentially with levels of nested views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joel Jacobson" <joel(at)compiler(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Planning time grows exponentially with levels of nested views
Date: 2021-04-18 20:41:53
Message-ID: 141461.1618778513@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

I wrote:
> If multiple references are actually possible then this'd break it. There
> seem to be no such cases in the regression tests though, and I'm having a
> hard time wrapping my brain around what would cause it. "git blame"
> traces this text to my own commit f44639e1b, which has the log entry
> Don't crash if subquery appears multiple times in jointree. This should
> not happen anyway, but let's try not to get completely confused if it does
> (due to rewriter bugs or whatever).
> so I'm thinking that this was only hypothetical.

Ah, found it. That was evidently a reaction to the immediately preceding
commit (352871ac9), which fixed a rewriter bug that could lead to exactly
the case of multiple jointree references to one RTE.

I think this patch doesn't make things any worse for such a case though.
If we re-introduced such a bug, the result would be an immediate null
pointer crash while trying to process the second reference to a
flattenable subquery. That's probably better for debuggability than
what happens now, where we just silently process the duplicate reference.

Anyway, I've stuck this into the next CF for future consideration.

regards, tom lane

PS: to save time for anyone else who wants to investigate this,
it looks like the report mentioned in 352871ac9 was

https://www.postgresql.org/message-id/007401c0860d%24bed809a0%241001a8c0%40archonet.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joel Jacobson 2021-04-18 20:42:11 Re: Planning time grows exponentially with levels of nested views
Previous Message Tom Lane 2021-04-18 20:14:07 Re: Planning time grows exponentially with levels of nested views

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2021-04-18 20:42:11 Re: Planning time grows exponentially with levels of nested views
Previous Message Yura Sokolov 2021-04-18 20:29:03 Re: Old Postgresql version on i7-1165g7