|From:||Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>|
|To:||Pg Hackers <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||expanding inheritance in partition bound order|
|Views:||Raw Message | Whole Thread | Download mbox|
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 .
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 , 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.
|Next Message||Amit Langote||2017-08-04 07:41:02||Re: UPDATE of partition key|
|Previous Message||Michael Paquier||2017-08-04 06:21:41||Re: Support for Secure Transport SSL library on macOS as OpenSSL alternative|