pgsql: Allow direct lookups of AppendRelInfo by child relid - Mailing list pgsql-committers

From Alvaro Herrera
Subject pgsql: Allow direct lookups of AppendRelInfo by child relid
Date
Msg-id E1fXpBA-0005UN-Kd@gemulon.postgresql.org
Whole thread Raw
List 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(-)


pgsql-committers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: pgsql: Increase upper limit for vacuum_cleanup_index_scale_factor
Next
From: Fujii Masao
Date:
Subject: pgsql: Fix documentation bug related to backup history file.