From e1f37f4c5c1ec7fcf1d91f47fd615d4ea61a2a46 Mon Sep 17 00:00:00 2001 From: amit Date: Fri, 12 Oct 2018 19:12:53 +0900 Subject: [PATCH v9 6/6] Do not lock all partitions at the beginning --- src/backend/optimizer/util/append.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/backend/optimizer/util/append.c b/src/backend/optimizer/util/append.c index 7227eed4c4..9b3fc41a1e 100644 --- a/src/backend/optimizer/util/append.c +++ b/src/backend/optimizer/util/append.c @@ -317,10 +317,6 @@ expand_inherited_rtentry(PlannerInfo *root, RangeTblEntry *rte, Index rti, * * Partitions are added to the query in order in which they are found in * the parent's PartitionDesc. - * - * Note: even though only the unpruned partitions will be added to the - * resulting plan, this still locks *all* partitions via find_all_inheritors - * when this function is called for the root partitioned table. */ static void expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte, @@ -334,10 +330,6 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte, parentrel->inh_root_parent : parentRTindex; - /* If root partitioned table, lock *all* partitions in the tree. */ - if (parentRTindex == rootParentRTindex) - (void) find_all_inheritors(parentrte->relid, lockmode, NULL); - /* * Initialize partitioned_child_rels to contain this RT index. * @@ -373,8 +365,7 @@ expand_partitioned_rtentry(PlannerInfo *root, RangeTblEntry *parentrte, RangeTblEntry *childrte; Index childRTindex; - /* Already locked above. */ - newrelation = heap_open(childOID, NoLock); + newrelation = heap_open(childOID, lockmode); Assert(!RELATION_IS_OTHER_TEMP(newrelation)); /* -- 2.11.0