[HACKERS] expanding inheritance in partition bound order
От | Amit Langote |
---|---|
Тема | [HACKERS] expanding inheritance in partition bound order |
Дата | |
Msg-id | 0118a1f2-84bb-19a7-b906-dec040a206f2@lab.ntt.co.jp обсуждение исходный текст |
Ответы |
Re: [HACKERS] expanding inheritance in partition bound order
Re: [HACKERS] expanding inheritance in partition bound order |
Список | pgsql-hackers |
The current way to expand inherited tables, including partitioned tables, is to use either find_all_inheritors() or find_inheritance_children() depending on the context. They return child table OIDs in the (ascending) order of those OIDs, which means the callers that need to lock the child tables can do so without worrying about the possibility of deadlock in some concurrent execution of that piece of code. That's good. For partitioned tables, there is a possibility of returning child table (partition) OIDs in the partition bound order, which in addition to preventing the possibility of deadlocks during concurrent locking, seems potentially useful for other caller-specific optimizations. For example, tuple-routing code can utilize that fact to implement binary-search based partition-searching algorithm. For one more example, refer to the "UPDATE partition key" thread where it's becoming clear that it would be nice if the planner had put the partitions in bound order in the ModifyTable that it creates for UPDATE of partitioned tables [1]. So attached are two WIP patches: 0001 implements two interface functions: List *get_all_partition_oids(Oid, LOCKMODE) List *get_partition_oids(Oid, LOCKMODE) that resemble find_all_inheritors() and find_inheritance_children(), respectively, but expect that users call them only for partitioned tables. Needless to mention, OIDs are returned with canonical order determined by that of the partition bounds and they way partition tree structure is traversed (top-down, breadth-first-left-to-right). Patch replaces all the calls of the old interface functions with the respective new ones for partitioned table parents. That means expand_inherited_rtentry (among others) now calls get_all_partition_oids() if the RTE is for a partitioned table and find_all_inheritors() otherwise. In its implementation, get_all_partition_oids() calls RelationGetPartitionDispatchInfo(), which is useful to generate the result list in the desired partition bound order. But the current interface and implementation of RelationGetPartitionDispatchInfo() needs some rework, because it's too closely coupled with the executor's tuple routing code. Applying just 0001 will satisfy the requirements stated in [1], but it won't look pretty as is for too long. So, 0002 is a patch to refactor RelationGetPartitionDispatchInfo() and relevant data structures. For example, PartitionDispatchData has now been simplified to contain only the partition key, partition descriptor and indexes array, whereas previously it also stored the relation descriptor, partition key execution state, tuple table slot, tuple conversion map which are required for tuple-routing. RelationGetPartitionDispatchInfo() no longer generates those things, but returns just enough information so that a caller can generate and manage those things by itself. This simplification makes it less cumbersome to call RelationGetPartitionDispatchInfo() in other places. Thanks, Amit [1] https://www.postgresql.org/message-id/CA%2BTgmoajC0J50%3D2FqnZLvB10roY%2B68HgFWhso%3DV_StkC6PWujQ%40mail.gmail.com -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Вложения
В списке pgsql-hackers по дате отправления: