]> granicus.if.org Git - postgresql/commit
Allow direct lookups of AppendRelInfo by child relid
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 26 Jun 2018 14:35:26 +0000 (10:35 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Tue, 26 Jun 2018 14:35:26 +0000 (10:35 -0400)
commit7d872c91a3f9d49b56117557cdbb0c3d4c620687
tree4625ac6dcba79056ffd04adc01c3a50409452255
parent6ca33a885bf892a7fa34020a2620c83ccec3cdd7
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
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planner.c
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/util/relnode.c
src/include/nodes/relation.h
src/include/optimizer/pathnode.h