pgsql: Allow direct lookups of AppendRelInfo by child relid

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Allow direct lookups of AppendRelInfo by child relid
Date: 2018-06-26 14:42:48
Message-ID: E1fXpBA-0005UN-Kd@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2018-06-26 15:53:24 pgsql: Fix documentation bug related to backup history file.
Previous Message Alexander Korotkov 2018-06-26 13:11:16 Re: pgsql: Increase upper limit for vacuum_cleanup_index_scale_factor