From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Improve planner's handling of SetOp plans. |
Date: | 2024-12-19 22:03:01 |
Message-ID: | E1tOObk-000PxL-HW@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Improve planner's handling of SetOp plans.
Remove the code for inserting flag columns in the inputs of a SetOp.
That was the only reason why there would be resjunk columns in a
set-operations plan tree, so we can get rid of some code that
supported that, too.
Get rid of choose_hashed_setop() in favor of building Paths for
the hashed and sorted alternatives, and letting them fight it out
within add_path().
Remove set_operation_ordered_results_useful(), which was giving wrong
answers due to examining the wrong ancestor node: we need to examine
the immediate SetOperationStmt parent not the topmost node. Instead
make each caller of recurse_set_operations() pass down the relevant
parent node. (This thinko seems to have led only to wasted planning
cycles and possibly-inferior plans, not wrong query answers. Perhaps
we should back-patch it, but I'm not doing so right now.)
Teach generate_nonunion_paths() to consider pre-sorted inputs for
sorted SetOps, rather than always generating a Sort node.
Patch by me; thanks to Richard Guo and David Rowley for review.
Discussion: https://postgr.es/m/1850138.1731549611@sss.pgh.pa.us
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8d96f57d5cc79c0c51050bb707c19bf07d2895eb
Modified Files
--------------
src/backend/optimizer/plan/planner.c | 7 +-
src/backend/optimizer/prep/prepunion.c | 478 ++++++++++++--------------------
src/backend/optimizer/util/pathnode.c | 69 ++++-
src/include/optimizer/prep.h | 1 -
src/test/regress/expected/subselect.out | 48 +++-
src/test/regress/expected/union.out | 53 ++--
src/test/regress/sql/subselect.sql | 32 ++-
src/test/regress/sql/union.sql | 9 +
8 files changed, 365 insertions(+), 332 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2024-12-19 22:07:25 | pgsql: Use ExecGetCommonSlotOps infrastructure in more places. |
Previous Message | Melanie Plageman | 2024-12-19 16:57:38 | pgsql: Remove extra prefetch iterator setup for Bitmap Table Scan |