Re: Converting SetOp to read its two inputs separately
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, David Rowley <dgrowleyml@gmail.com>
Date: 2024-11-20T02:09:36Z
Lists: pgsql-hackers
Attachments
- v2-0001-Convert-SetOp-to-read-its-inputs-as-outerPlan-and.patch (text/x-diff) patch v2-0001
- v2-0002-Remove-some-dead-code-in-prepunion.c.patch (text/x-diff) patch v2-0002
- v2-0003-Get-rid-of-choose_hashed_setop.patch (text/x-diff) patch v2-0003
- v2-0004-Fix-bogus-decisions-about-whether-we-want-pre-sor.patch (text/x-diff) patch v2-0004
- v2-0005-Teach-generate_nonunion_paths-to-consider-pre-sor.patch (text/x-diff) patch v2-0005
Richard Guo <guofenglinux@gmail.com> writes: > On Thu, Nov 14, 2024 at 11:00 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> Aside from that minor TODO, the main thing that's left undone in this >> patch series is to persuade the thing to exploit presorted input >> paths. > I think we may need to do the following to make this work: > 1. We need to teach set_operation_ordered_results_useful() that sorted > input paths are also useful for INTERSECT/EXCEPT, so that we can have > setop_pathkeys set for the subqueries. > 2. In generate_nonunion_paths(), we need to provide a valid > "interesting_pathkeys" when calling build_setop_child_paths(). Once I'd wrapped my head around how things are done now (which the comments in prepunion.c were remarkably unhelpful about), I saw that most of the problem for #2 just requires re-ordering things that generate_nonunion_paths was already doing. As for #1, I have a modest proposal: we should get rid of set_operation_ordered_results_useful entirely. It's not the code that actually does useful work, and keeping it in sync with the code that does do useful work is hard and unnecessary. 0001-0003 below are the same as before (so the slot-munging TODO is still there). 0004 fixes a rather basic bug for nested set-operations and gets rid of set_operation_ordered_results_useful along the way. Then 0005 does your step 2. regards, tom lane
Commits
-
Get rid of old version of BuildTupleHashTable().
- e0a2721f7c16 18.0 landed
-
Use ExecGetCommonSlotOps infrastructure in more places.
- f0b900086a37 18.0 landed
-
Improve planner's handling of SetOp plans.
- 8d96f57d5cc7 18.0 landed
-
Convert SetOp to read its inputs as outerPlan and innerPlan.
- 27627929528e 18.0 landed
-
Fix typo in header comment for set_operation_ordered_results_useful
- b6612aedc53a 18.0 landed
-
Allow planner to use Merge Append to efficiently implement UNION
- 66c0185a3d14 17.0 cited