0006-Do-not-lock-all-partitions-at-the-beginning.patch

text/plain

Filename: 0006-Do-not-lock-all-partitions-at-the-beginning.patch
Type: text/plain
Part: 5
Message: Re: speeding up planning with partitions

Patch

Format: format-patch
Series: patch 0006
Subject: Do not lock all partitions at the beginning
File+
src/backend/optimizer/util/append.c 1 6
From 90d20b1adf71ae3a335687d97fe7c51426095968 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Fri, 12 Oct 2018 19:12:53 +0900
Subject: [PATCH 6/6] Do not lock all partitions at the beginning

---
 src/backend/optimizer/util/append.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/backend/optimizer/util/append.c b/src/backend/optimizer/util/append.c
index 4202a4e00d..4080dea041 100644
--- a/src/backend/optimizer/util/append.c
+++ b/src/backend/optimizer/util/append.c
@@ -150,10 +150,6 @@ expand_append_rel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte,
 		Assert(rte->rtekind == RTE_RELATION);
 		Assert(lockmode != NoLock);
 
-		/* If root partitioned table, lock *all* partitions in the tree. */
-		if (rel->relid == root_parent)
-			(void) find_all_inheritors(rte->relid, lockmode, NULL);
-
 		/*
 		 * Initialize partitioned_child_rels to contain this RT index.
 		 *
@@ -187,10 +183,9 @@ expand_append_rel(PlannerInfo *root, RelOptInfo *rel, RangeTblEntry *rte,
 			Oid		childOID = rel->part_oids[i];
 			RelOptInfo *childrel;
 
-			/* Already locked, so pass NoLock. */
 			childrel = add_inheritance_child_rel(root, rel, rte,
 												 childOID,
-												 NoLock,
+												 lockmode,
 												 rootrc);
 			rel->part_rels[i] = childrel;
 
-- 
2.11.0