aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-12-22 11:02:03 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2022-12-22 11:02:03 -0500
commite42e312430279dcd8947846fdfeb4885e3754eac (patch)
treeedc5e71e7b7e5aa357117a5f42dc728d96415e64 /src/backend/commands/cluster.c
parent5beb7881fb27d1830fa4c57ba263c8042449a599 (diff)
downloadpostgresql-e42e312430279dcd8947846fdfeb4885e3754eac.tar.gz
postgresql-e42e312430279dcd8947846fdfeb4885e3754eac.zip
Avoid O(N^2) cost when pulling up lots of UNION ALL subqueries.
perform_pullup_replace_vars() knows how to scan the whole parent query tree when we are replacing Vars during a subquery flattening operation. However, for the specific case of flattening a UNION ALL leaf query, that's mostly wasted work: the only place where relevant Vars could exist is in the AppendRelInfo that we just made for this leaf. Teaching perform_pullup_replace_vars() to just deal with that and exit is worthwhile because, if we have N such subqueries to pull up, we were spending O(N^2) work uselessly mutating the AppendRelInfos for all the other subqueries. While we're at it, avoid calling substitute_phv_relids if there are no PlaceHolderVars, and remove an obsolete check of parse->hasSubLinks. Andrey Lepikhov and Tom Lane Discussion: https://postgr.es/m/703c09a2-08f3-d2ec-b33d-dbecd62428b8@postgrespro.ru
Diffstat (limited to 'src/backend/commands/cluster.c')
0 files changed, 0 insertions, 0 deletions