v27-0006-Don-t-copy-PartitionBoundInfo-in-set_relation_pa.patch
text/plain
Filename: v27-0006-Don-t-copy-PartitionBoundInfo-in-set_relation_pa.patch
Type: text/plain
Part: 5
Patch
Format: format-patch
Series: patch v27-0006
Subject: Don't copy PartitionBoundInfo in set_relation_partition_info
| File | + | − |
|---|---|---|
| src/backend/optimizer/util/plancat.c | 5 | 3 |
From 791faa4f6e1ef1ba5b5e1963aaaacd68c02acc71 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Mon, 4 Mar 2019 16:03:49 +0900
Subject: [PATCH v27 6/6] Don't copy PartitionBoundInfo in
set_relation_partition_info
As long as we hold a lock on the table, it shouldn't change, so
seems pointless to copy, which can get really expensive as the
number of partitions grows beyond thousands.
---
src/backend/optimizer/util/plancat.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 549af9dc6e..b75b761033 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -2082,16 +2082,18 @@ set_relation_partition_info(PlannerInfo *root, RelOptInfo *rel,
Relation relation)
{
PartitionDesc partdesc;
- PartitionKey partkey;
Assert(relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
partdesc = RelationGetPartitionDesc(relation);
- partkey = RelationGetPartitionKey(relation);
rel->part_scheme = find_partition_scheme(root, relation);
Assert(partdesc != NULL && rel->part_scheme != NULL);
+ /*
+ * Holding onto the relcache pointer should be OK, as it won't change
+ * under us as long as we're holding the lock on the relation.
+ */
if (partdesc->nparts > 0)
- rel->boundinfo = partition_bounds_copy(partdesc->boundinfo, partkey);
+ rel->boundinfo = partdesc->boundinfo;
rel->nparts = partdesc->nparts;
set_baserel_partition_key_exprs(relation, rel);
rel->partition_qual = RelationGetPartitionQual(relation);
--
2.11.0