Re: generic plans and "initial" pruning
Amit Langote <amitlangote09@gmail.com>
Attachments
- v5-0002-Add-a-plan_tree_walker.patch (application/octet-stream) patch v5-0002
- v5-0003-Teach-AcquireExecutorLocks-to-skip-locking-pruned.patch (application/octet-stream) patch v5-0003
- v5-0001-Some-refactoring-of-runtime-pruning-code.patch (application/octet-stream) patch v5-0001
On Mon, Mar 7, 2022 at 11:18 PM Amit Langote <amitlangote09@gmail.com> wrote: > On Fri, Feb 11, 2022 at 7:02 AM Robert Haas <robertmhaas@gmail.com> wrote: > > I don't love PlanPrepOutput the way you have it. I think one of the > > basic design issues for this patch is: should we think of the prep > > phase as specifically pruning, or is it general prep and pruning is > > the first thing for which we're going to use it? If it's really a > > pre-pruning phase, we could name it that way instead of calling it > > "prep". If it's really a general prep phase, then why does > > PlanPrepOutput contain initially_valid_subnodes as a field? One could > > imagine letting each prep function decide what kind of prep node it > > would like to return, with partition pruning being just one of the > > options. But is that a useful generalization of the basic concept, or > > just pretending that a special-purpose mechanism is more general than > > it really is? > > While it can feel like the latter TBH, I'm inclined to keep > ExecutorPrep generalized. What bothers me about about the > alternative of calling the new phase something less generalized like > ExecutorDoInitPruning() is that that makes the somewhat elaborate API > changes needed for the phase's output to put into QueryDesc, through > which it ultimately reaches the main executor, seem less worthwhile. > > I agree that PlanPrepOutput design needs to be likewise generalized, > maybe like you suggest -- using PlanInitPruningOutput, a child class > of PlanPrepOutput, to return the prep output for plan nodes that > support pruning. > > Thoughts? So I decided to agree with you after all about limiting the scope of this new executor interface, or IOW call it what it is. I have named it ExecutorGetLockRels() to go with the only use case we know for it -- get the set of relations for AcquireExecutorLocks() to lock to validate a plan tree. Its result returned in a node named ExecLockRelsInfo, which contains the set of relations scanned in the plan tree (lockrels) and a list of PlanInitPruningOutput nodes for all nodes that undergo pruning. > > + return CreateQueryDesc(pstmt, NULL, /* XXX pass ExecPrepOutput too? */ > > > > It seems to me that we should do what the XXX suggests. It doesn't > > seem nice if the parallel workers could theoretically decide to prune > > a different set of nodes than the leader. > > OK, will fix. Done. This required adding nodeToString() and stringToNode() support for the nodes produced by the new executor function that wasn't there before. > > Somewhere, we're going to need to document the idea that this may > > permit us to execute a plan that isn't actually fully valid, but that > > we expect to survive because we'll never do anything with the parts of > > it that aren't. Maybe that should be added to the executor README, or > > maybe there's some better place, but I don't think that should remain > > something that's just implicit. > > Agreed. I'd added a description of the new prep phase to executor > README, though the text didn't mention this particular bit. Will fix > to mention it. Rewrote the comments above ExecutorGetLockRels() (previously ExecutorPrep()) and the executor README text to be explicit about the fact that not locking some relations effectively invalidates pruned parts of the plan tree. > > This is not a full review, just some initial thoughts looking through this. > > Thanks again. Will post a new version soon after a bit more polishing. Attached is v5, now broken into 3 patches: 0001: Some refactoring of runtime pruning code 0002: Add a plan_tree_walker 0003: Teach AcquireExecutorLocks to skip locking pruned relations -- Amit Langote EDB: http://www.enterprisedb.com
Commits
-
Stamp 19beta1.
- 4b0bf0788b06 19 (unreleased) cited
-
Revert "Don't lock partitions pruned by initial pruning"
- 1722d5eb05d8 18.0 landed
-
Ensure first ModifyTable rel initialized if all are pruned
- 28317de723b6 18.0 cited
-
Fix bug in cbc127917 to handle nested Append correctly
- cbb9086c9ef6 18.0 landed
-
Remove unstable test suite added by 525392d57
- 4f1b6e5bb4fe 18.0 landed
-
Don't lock partitions pruned by initial pruning
- 525392d5727f 18.0 landed
-
Fix an oversight in cbc127917 to handle MERGE correctly
- 75dfde13639a 18.0 landed
-
Track unpruned relids to avoid processing pruned relations
- cbc127917e04 18.0 landed
-
Perform runtime initial pruning outside ExecInitNode()
- d47cbf474ecb 18.0 landed
-
Move PartitionPruneInfo out of plan nodes into PlannedStmt
- bb3ec16e14de 18.0 landed
-
Fix setrefs.c's failure to do expression processing on prune steps.
- bf826ea06297 18.0 cited
-
Remove obsolete executor cleanup code
- d060e921ea5a 17.0 landed
-
Revert "Move PartitionPruneInfo out of plan nodes into PlannedStmt"
- 5472743d9e85 16.0 landed
-
Move PartitioPruneInfo out of plan nodes into PlannedStmt
- ec386948948c 16.0 landed
-
Refactor and cleanup runtime partition prune code a little
- 297daa9d4353 15.0 landed
-
Remove some unnecessary fields from Plan trees.
- 52ed730d511b 12.0 cited
-
Remove more redundant relation locking during executor startup.
- f2343653f5b2 12.0 cited
-
Shut down Gather's children before shutting down Gather itself.
- acf555bc53ac 10.0 cited