Re: Significant Execution Time Difference Between PG13.14 and PG16.4 for Query on information_schema Tables.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: nikhil raj <nikhilraj474(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Significant Execution Time Difference Between PG13.14 and PG16.4 for Query on information_schema Tables.
Date: 2024-08-27 21:52:12
Message-ID: 3147330.1724795532@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

I wrote:
> We didn't see this particular behavior before 2489d76c49 because
> pullup_replace_vars avoided inserting a PHV:
> * If it contains a Var of the subquery being pulled up, and
> * does not contain any non-strict constructs, then it's
> * certainly nullable so we don't need to insert a
> * PlaceHolderVar.
> I dropped that case in 2489d76c49 because now we need to attach
> nullingrels to the expression. You could imagine attaching the
> nullingrels to the contained Var(s) instead of putting a PHV on top,
> but that seems like a mess and I'm not quite sure it's semantically
> the same. In any case it wouldn't fix adjacent cases where there is
> a non-strict construct in the subquery output expression.

I realized that actually we do have the mechanism for making that
work: we could apply add_nulling_relids to the expression, if it
meets those same conditions. This is a kluge really, but it would
restore the status quo ante in a fairly localized fashion that
seems like it might be safe enough to back-patch into v16.

Here's a WIP patch that does it like that. One problem with it
is that it requires rcon->relids to be calculated in cases where
we didn't need that before, which is probably not *that* expensive
but it's annoying. If we go forward with this, I'm thinking about
changing add_nulling_relids' API contract to say "if target_relid
is NULL then all level-zero Vars/PHVs are modified", so that we
don't need that relid set in non-LATERAL cases.

The other problem with this is that it breaks one test case in
memoize.sql: a query that formerly generated a memoize plan
now does not use memoize. I am not sure why not --- does that
mean anything to you?

regards, tom lane

Attachment Content-Type Size
avoid-unnecessary-PHV-during-pullup-wip.patch text/x-diff 4.6 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2024-08-27 22:24:52 Re: tsvector limitations - why and how
Previous Message Stanislav Kozlovski 2024-08-27 20:38:03 tsvector limitations - why and how

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2024-08-27 21:56:53 Re: pg_upgrade: Support for upgrading to checksums enabled
Previous Message Jeff Davis 2024-08-27 21:43:59 Re: Introduce new multi insert Table AM and improve performance of various SQL commands with it for Heap AM