pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make PlaceHolderInfo lookup O(1).
Date: Wed, 17 Aug 2022 20:12:45 +0000
Message-ID: <E1oOPPA-0000Zt-RL@gemulon.postgresql.org> (raw)

Make PlaceHolderInfo lookup O(1).

Up to now we've just searched the placeholder_list when we want to
find the PlaceHolderInfo with a given ID.  While there's no evidence
of that being a problem in the field, an upcoming patch will add
find_placeholder_info() calls in build_joinrel_tlist(), which seems
likely to make it more of an issue: a joinrel emitting lots of
PlaceHolderVars would incur O(N^2) cost, and we might be building
a lot of joinrels in complex queries.  Hence, add an array that
can be indexed directly by phid to make the lookups constant-time.

Discussion: https://postgr.es/m/1405792.1660677844@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6569ca43973b754e8213072c8ddcae9e7baf2aaa

Modified Files
--------------
src/backend/optimizer/plan/analyzejoins.c |  3 +++
src/backend/optimizer/plan/planmain.c     |  2 ++
src/backend/optimizer/util/placeholder.c  | 43 +++++++++++++++++++++++++++----
src/backend/optimizer/util/var.c          | 11 ++------
src/include/nodes/pathnodes.h             |  5 ++++
5 files changed, 50 insertions(+), 14 deletions(-)



Message-ID: <E1oOPPA-0000Zt-RL@gemulon.postgresql.org>
Permalink:  ../E1oOPPA-0000Zt-RL@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1oOPPA-0000Zt-RL@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Make PlaceHolderInfo lookup O(1).
  In-Reply-To: <E1oOPPA-0000Zt-RL@gemulon.postgresql.org>
  References: <E1oOPPA-0000Zt-RL@gemulon.postgresql.org>

* 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