Re: why partition pruning doesn't work?
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>,
Dmitry Dolgov <9erthalion6@gmail.com>, Jeff Janes <jeff.janes@gmail.com>,
Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>, Pavel Stehule <pavel.stehule@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-06-11T14:40:25Z
Lists: pgsql-hackers
On 12 June 2018 at 02:26, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> However, if you didn't mean removing the executor >> initialise pruning, and just not remapping the arrays, then I'm not >> sure how we'd do that. I'd previously tried having NULL subnodes in >> the Append and I thought it required too much hacking work in >> explain.c, so I decided to just collapse the array instead and do what >> was required to make it work after having removed the unneeded >> subplans. Did you have another idea on how to do this? > > No, that was pretty much exactly what I was envisioning. I have > not looked at the consequences for explain.c but it seemed like > it couldn't be all that bad; and to my mind the remapping business > in the partition code is pretty bad. "It's all in one file" is not > a suitable justification for unintelligible, overcomplex code. By all means, please have a look then. I've been down that route. I didn't like it. I particularly think the memory fragmentation is very good grounds for a good cache hit ratio either, not to mention the slowdown of bms_next_member when there are large gaps in the set. Keep in mind that we may scan the Append many times over when it's on the inside of a nested loop join. What you're proposing exchanges logic that fits neatly into one function for special logic that will be scattered all over explain.c. I really don't think that's the better of the two evils. I'd rather just see my last patch applied which simplifies the re-map code by removing the 2nd loop. Actually, even updating the present_parts to remove the unneeded subpartitioned table indexes is optional. We' just need to give up on the elog(ERROR, "partition missing from subplans"); error and assume that case is fine. -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Fix up run-time partition pruning's use of relcache's partition data.
- e23bae82cf3d 11.0 landed
-
Fix access to just-closed relcache entry.
- bdc643e5e46f 11.0 landed
- b10edaf4bb44 10.5 landed
-
Improve ExecFindInitialMatchingSubPlans's subplan renumbering logic.
- 69025c5a07a1 11.0 landed
-
Improve commentary about run-time partition pruning data structures.
- 4e2323640333 11.0 landed
-
Fix run-time partition pruning code to handle NULL values properly.
- be3d90026a3c 11.0 landed
-
Assorted cosmetic cleanup of run-time-partition-pruning code.
- 321f648a312b 11.0 landed
-
Relocate partition pruning structs to a saner place.
- 939449de0e57 11.0 landed
-
Improve run-time partition pruning to handle any stable expression.
- 73b7f48f78d2 11.0 landed
-
Support partition pruning at execution time
- 499be013de65 11.0 cited