Re: [HACKERS] Runtime Partition Pruning
Amit Langote <langote_amit_f8@lab.ntt.co.jp>
From: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
To: David Rowley <david.rowley@2ndquadrant.com>,
Beena Emerson <memissemerson@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, amul sul <sulamul@gmail.com>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Dilip Kumar <dilipbalaut@gmail.com>
Date: 2017-12-18T08:31:20Z
Lists: pgsql-hackers
Hi. On 2017/12/16 15:05, David Rowley wrote: > On 13 December 2017 at 00:33, Beena Emerson <memissemerson@gmail.com> wrote: >> PFA the updated patch, this can be applied over the v13 patches [1] >> over commit 487a0c1518af2f3ae2d05b7fd23d636d687f28f3 > > Hi Beena, > > Thanks for posting an updated patch. > > I've been looking over this and I think that the use of the > PartitionDispatch in set_append_subplan_indexes is not correct. What > we need here is the index of the Append's subnode and that's not what > RelationGetPartitionDispatchInfo() gives you. Remember that some > partitions could have been pruned away already during planning. A somewhat similar concern is being discussed on the "UPDATE partition key" thread [1]. In that case, ExecInitModifyTable(), when initializing tuple routing information to handle the "update partition key" case, will have to deal with the fact that there might be fewer sub-plans in the ModifyTable node than there are partitions in the partition tree. That is, source partitions that planner would have determined after pruning, could be fewer than possible target partitions for rows from the source partitions to move to, of which the latter consists of *all* partitions. So, we have to have a mapping from leaf partition indexes as figured out by RelationGetPartitionDispatchInfo() (indexes that are offsets into a global array for *all* partitions), to sub-plan indexes which are offsets into the array for only those partitions that have a sub-plan. Such mapping is built (per the latest patch on that thread) by ExecSetupPartitionTupleRouting() in execPartition.c. We could do something similar here using a similar code structure. Maybe, add a ExecSetupPartitionRuntimePruning() in execPartition.c (mimicking ExecSetupPartitionTupleRouting), that accepts AppendState node. Furthermore, it might be a good idea to have something similar to ExecFindPartition(), say, ExecGetPartitions(). That is, we have new functions for run-time pruning that are counterparts to corresponding functions for tuple routing. Thanks, Amit [1] https://www.postgresql.org/message-id/c5e1d4ad-d243-52c5-608b-5dbb7183e465%40lab.ntt.co.jp
Commits
-
Initialize ExprStates once in run-time partition pruning
- 1957f8dabf8d 11.0 landed
-
Add bms_prev_member function
- 5c0675215e15 11.0 landed
-
Support partition pruning at execution time
- 499be013de65 11.0 landed
-
Document partprune.c a little better
- 971d7ddbe19a 11.0 landed
-
Fix crash in pg_replication_slot_advance
- 6f1d723b6359 11.0 cited
-
Add parallel-aware hash joins.
- 1804284042e6 11.0 cited
-
Fix typo.
- 487a0c1518af 11.0 cited
-
Allow --with-bonjour to work with non-macOS implementations of Bonjour.
- 9b9cb3c4534d 11.0 cited
-
Mention need for --no-inc-recursive in rsync command
- 2c74e6c1dcc5 11.0 cited