Store information about Append node consolidation in the final plan. An extension (or core code) might want to reconstruct the planner's decisions about whether and where to perform partitionwise joins from the final plan. To do so, it must be possible to find all of the RTIs of partitioned tables appearing in the plan. But when an AppendPath or MergeAppendPath pulls up child paths from a subordinate AppendPath or MergeAppendPath, the RTIs of the subordinate path do not appear in the final plan, making this kind of reconstruction impossible.
To avoid this, propagate the RTI sets that would have been present in the 'apprelids' field of the subordinate Append or MergeAppend nodes that would have been created into the surviving Append or MergeAppend node, using a new 'child_append_relid_sets' field for that purpose. The value of this field is a list of Bitmapsets, because each relation whose append-list was pulled up had its own set of RTIs: just one, if it was a partitionwise scan, or more than one, if it was a partitionwise join. Since our goal is to see where partitionwise joins were done, it is essential to avoid losing the information about how the RTIs were grouped in the pulled-up relations. This commit also updates pg_overexplain so that EXPLAIN (RANGE_TABLE) will display the saved RTI sets. Co-authored-by: Robert Haas <[email protected]> Co-authored-by: Lukas Fittl <[email protected]> Reviewed-by: Lukas Fittl <[email protected]> Reviewed-by: Jakub Wartak <[email protected]> Reviewed-by: Greg Burd <[email protected]> Reviewed-by: Jacob Champion <[email protected]> Reviewed-by: Amit Langote <[email protected]> Reviewed-by: Haibo Yan <[email protected]> Reviewed-by: Alexandra Wang <[email protected]> Discussion: http://postgr.es/m/CA+TgmoZ-Jh1T6QyWoCODMVQdhTUPYkaZjWztzP1En4=zhok...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7358abcc6076f4b2530d10126ab379f8aea612a5 Modified Files -------------- contrib/pg_overexplain/expected/pg_overexplain.out | 10 +- contrib/pg_overexplain/pg_overexplain.c | 56 ++++++ src/backend/optimizer/path/allpaths.c | 199 +++++++++++++-------- src/backend/optimizer/path/joinrels.c | 3 +- src/backend/optimizer/plan/createplan.c | 2 + src/backend/optimizer/plan/planner.c | 7 +- src/backend/optimizer/prep/prepunion.c | 43 +++-- src/backend/optimizer/util/pathnode.c | 26 +-- src/include/nodes/pathnodes.h | 10 ++ src/include/nodes/plannodes.h | 11 ++ src/include/optimizer/pathnode.h | 18 +- src/tools/pgindent/typedefs.list | 1 + 12 files changed, 274 insertions(+), 112 deletions(-)
