pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Allow direct lookups of AppendRelInfo by child relid
Date: Tue, 26 Jun 2018 14:42:48 +0000
Message-ID: <E1fXpBA-0005UN-Kd@gemulon.postgresql.org> (raw)

Allow direct lookups of AppendRelInfo by child relid

find_appinfos_by_relids had quite a large overhead when the number of
items in the append_rel_list was high, as it had to trawl through the
append_rel_list looking for AppendRelInfos belonging to the given
childrelids.  Since there can only be a single AppendRelInfo for each
child rel, it seems much better to store an array in PlannerInfo which
indexes these by child relid, making the function O(1) rather than O(N).
This function was only called once inside the planner, so just replace
that call with a lookup to the new array.  find_childrel_appendrelinfo
is now unused and thus removed.

This fixes a planner performance regression new to v11 reported by
Thomas Reiss.

Author: David Rowley
Reported-by: Thomas Reiss
Reviewed-by: Ashutosh Bapat
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/94dd7a4b-5e50-0712-911d-2278e055c622@dalibo.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7d872c91a3f9d49b56117557cdbb0c3d4c620687

Modified Files
--------------
src/backend/optimizer/plan/planmain.c  |  6 +++
src/backend/optimizer/plan/planner.c   |  4 ++
src/backend/optimizer/prep/prepunion.c | 29 +++++++-------
src/backend/optimizer/util/relnode.c   | 70 +++++++++++++++++++---------------
src/include/nodes/relation.h           | 10 +++++
src/include/optimizer/pathnode.h       |  3 +-
6 files changed, 74 insertions(+), 48 deletions(-)



Message-ID: <E1fXpBA-0005UN-Kd@gemulon.postgresql.org>
Permalink:  ../E1fXpBA-0005UN-Kd@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1fXpBA-0005UN-Kd@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: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Allow direct lookups of AppendRelInfo by child relid
  In-Reply-To: <E1fXpBA-0005UN-Kd@gemulon.postgresql.org>
  References: <E1fXpBA-0005UN-Kd@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