Re: Get rid of runtime handling of AlternativeSubPlan?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-hackers@lists.postgresql.org
Date: 2020-08-29T23:26:36Z
Lists: pgsql-hackers
Attachments
- 0001-resolve-alternativesubplan-in-planner-1.patch (text/x-diff) patch 0001
- 0002-remove-alternativesubplan-executor-1.patch (text/x-diff) patch 0002
I wrote: > Back in bd3daddaf232d95b0c9ba6f99b0170a0147dd8af, which introduced > AlternativeSubPlans, I wrote: > There is a lot more that could be done based on this infrastructure: in > particular it's interesting to consider switching to the hash plan if we start > out using the non-hashed plan but find a lot more upper rows going by than we > expected. I have therefore left some minor inefficiencies in place, such as > initializing both subplans even though we will currently only use one. > > That commit will be twelve years old come August, and nobody has either > built anything else atop it or shown any interest in making the plan choice > switchable mid-run. So it seems like kind of a failed experiment. > > Therefore, I'm considering the idea of ripping out all executor support > for AlternativeSubPlan and instead having the planner replace an > AlternativeSubPlan with the desired specific SubPlan somewhere late in > planning, possibly setrefs.c. Here's a proposed patchset for that. This runs with the idea I'd had that setrefs.c could be smarter than the executor about which plan node subexpressions will be executed how many times. I did not take it very far, for fear of adding an undue number of planning cycles, but it's still better than what we have now. For ease of review, 0001 adds the new planner logic, while 0002 removes the now-dead executor support. There's one bit of dead code that I left in place for the moment, which is ruleutils.c's support for printing AlternativeSubPlans. I'm not sure if that's worth keeping or not --- it's dead code for normal use, but if someone tried to use ruleutils.c to print partially-planned expression trees, maybe there'd be a use for it? (It's also arguable that readfuncs.c's support is now dead code, but I have little interest in stripping that out.) regards, tom lane
Commits
-
Move resolution of AlternativeSubPlan choices to the planner.
- 41efb8340877 14.0 landed
-
Arrange to convert EXISTS subqueries that are equivalent to hashable IN
- bd3daddaf232 8.4.0 cited