Re: why partition pruning doesn't work?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: Robert Haas <robertmhaas@gmail.com>,
David Rowley <david.rowley@2ndquadrant.com>,
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-18T17:05:11Z
Lists: pgsql-hackers
Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> writes: > [ 0001-Open-partitioned-tables-during-Append-initialization.patch ] I took a look at this. While I'm in agreement with the general idea of holding open the partitioned relations' relcache entries throughout the query, I do not like anything about this patch: * It seems to be outright broken for the case that any of the partitioned relations are listed in nonleafResultRelations. If we're going to do it like this, we have to open every one of the partrels regardless of that. (I wonder whether we couldn't lose PlannedStmt.nonleafResultRelations altogether, in favor of merging the related code in InitPlan with this. That existing code is already a mighty ugly wart, and this patch makes it worse by adding new, related warts elsewhere.) * You've got *far* too much intimate knowledge of the possible callers in ExecOpenAppendPartitionedTables. Personally, what I would have this function do is return a List of the opened Relation pointers, and add a matching function to run through such a List and close the entries again, and make the callers responsible for stashing the List pointer in an appropriate field in their planstate. Or maybe what we should do is drop ExecLockNonLeafAppendTables/ ExecOpenAppendPartitionedTables entirely and teach InitPlan to do it. regards, tom lane
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