Re: Speeding up INSERTs and UPDATEs to partitioned tables
От | Jesper Pedersen |
---|---|
Тема | Re: Speeding up INSERTs and UPDATEs to partitioned tables |
Дата | |
Msg-id | 253139dd-4461-4932-2225-4a0345a2a7d1@redhat.com обсуждение исходный текст |
Ответ на | Re: Speeding up INSERTs and UPDATEs to partitioned tables (David Rowley <david.rowley@2ndquadrant.com>) |
Список | pgsql-hackers |
Hi David, On 11/7/18 6:46 AM, David Rowley wrote: > I've attached a patch which does this. It adds a new struct named > PartitionRoutingInfo into ResultRelInfo and pulls 3 of the 4 arrays > out of PartitionTupleRouting. There are fields for each of what these > arrays used to store inside the PartitionRoutingInfo struct. > > While doing this I kept glancing back over at ModifyTableState and at > the mt_per_subplan_tupconv_maps array. I wondered if it would be > better to make the PartitionRoutingInfo a bit more generic, perhaps > call it TupleConversionInfo and have fields like ti_ToGeneric and > ti_FromGeneric, with the idea that "generic" would be the root > partition or the first subplan for inheritance updates. This would > allow us to get rid of a good chunk of code inside nodeModifyTable.c. > However, I ended up not doing this and left PartitionRoutingInfo to be > specifically for Root to Partition conversion. > Yeah, it doesn't necessarily have to be part of this patch. > Also, on the topic about what to name the conversion maps from a few > days ago; After looking at this a bit more I decided that having them > named ParentToChild and ChildToParent is misleading. If the child is > the child of some sub-partitioned table then the parent that the map > is talking about is not the partition's parent, but the root > partitioned table. So really RootToPartition and PartitionToRoot seem > like much more accurate names for the maps. > Agreed. > I made a few other changes along the way; I thought that > ExecFindPartition() would be a good candidate to take on the > responsibility of validating the partition is valid for INSERTs when > it uses a partition out of the subplan_resultrel_hash. I thought it > was better to check this once when we're in the code path of grabbing > the ResultRelInfo out that hash table rather than in a code path that > must check if it's been done already each time we route a tuple into a > partition. It also allowed me to get rid of > ri_PartitionReadyForRouting. I also moved the call to > ExecInitRoutingInfo() into ExecFindPartition() which allowed me to > make that function static, which could result in the generation of > slightly more optimal compiled code. > > Please find attached the v14 patch. > Passes check-world, and has detailed documentation about the changes :) Best regards, Jesper
В списке pgsql-hackers по дате отправления: