From f649fc914ea0e2bc15e2f1387b4c56df9e27bec6 Mon Sep 17 00:00:00 2001 From: "dgrowley@gmail.com" Date: Fri, 9 Nov 2018 10:20:14 +1300 Subject: [PATCH v14 2/2] Unsafe locking reduction for partitioned INSERT/UPDATEs For performance demonstration purposes only. --- src/backend/executor/execPartition.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index 962db6d7f0..f37371f561 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -167,9 +167,6 @@ static void find_matching_subplans_recurse(PartitionPruningData *prunedata, * tuple routing for partitioned tables, encapsulates it in * PartitionTupleRouting, and returns it. * - * Note that all the relations in the partition tree are locked using the - * RowExclusiveLock mode upon return from this function. - * * Callers must use the returned PartitionTupleRouting during calls to * ExecFindPartition(). The actual ResultRelInfo for a partition is only * allocated when the first tuple is routed there. @@ -180,9 +177,6 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, Relation rel) PartitionTupleRouting *proute; ModifyTable *node = mtstate ? (ModifyTable *) mtstate->ps.plan : NULL; - /* Lock all the partitions. */ - (void) find_all_inheritors(RelationGetRelid(rel), RowExclusiveLock, NULL); - /* * Here we attempt to expend as little effort as possible in setting up * the PartitionTupleRouting. Each partition's ResultRelInfo is built on @@ -535,11 +529,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, bool found_whole_row; int part_result_rel_index; - /* - * We locked all the partitions in ExecSetupPartitionTupleRouting - * including the leaf partitions. - */ - partrel = heap_open(dispatch->partdesc->oids[partidx], NoLock); + partrel = heap_open(dispatch->partdesc->oids[partidx], RowExclusiveLock); /* * Keep ResultRelInfo and other information for this partition in the @@ -987,7 +977,7 @@ ExecInitPartitionDispatchInfo(PartitionTupleRouting *proute, Oid partoid, int dispatchidx; if (partoid != RelationGetRelid(proute->partition_root)) - rel = heap_open(partoid, NoLock); + rel = heap_open(partoid, RowExclusiveLock); else rel = proute->partition_root; partdesc = RelationGetPartitionDesc(rel); -- 2.16.2.windows.1