Re: generic plans and "initial" pruning
Tom Lane <tgl@sss.pgh.pa.us>
Robert Haas <robertmhaas@gmail.com> writes: > In my opinion, the most important theoretical issue here is around > reuse of plans that are no longer entirely valid, but the parts that > are no longer valid are certain to be pruned. If, because we know that > some parameter has some particular value, we skip locking a bunch of > partitions, then when we're executing the plan, those partitions need > not exist any more -- or they could have different indexes, be > detached from the partitioning hierarchy and subsequently altered, > whatever. Check. > That seems fine to me provided that all of our code (and any > third-party code) is careful not to rely on the portion of the plan > that we've pruned away, and doesn't assume that (for example) we can > still fetch the name of an index whose OID appears in there someplace. ... like EXPLAIN, for example? If "pruning" means physical removal from the plan tree, then it's probably all right. However, it looks to me like that doesn't actually happen, or at least doesn't happen till much later, so there's room for worry about a disconnect between what plancache.c has verified and what executor startup will try to touch. As you say, in the absence of any bugs, that's not a problem ... but if there are such bugs, tracking them down would be really hard. What I am skeptical about is that this work actually accomplishes anything under real-world conditions. That's because if pruning would save enough to make skipping the lock-acquisition phase worth the trouble, the plan cache is almost certainly going to decide it should be using a custom plan not a generic plan. Now if we had a better cost model (or, indeed, any model at all) for run-time pruning effects then maybe that situation could be improved. I think we'd be better served to worry about that end of it before we spend more time making the executor even less predictable. Also, while I've not spent much time at all reading this patch, it seems rather desperately undercommented, and a lot of the new names are unintelligible. In particular, I suspect that the patch is significantly redesigning when/where run-time pruning happens (unless it's just letting that be run twice); but I don't see any documentation or name changes suggesting where that responsibility is now. regards, tom lane
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