v31-0008-Don-t-copy-PartitionBoundInfo-in-set_relation_pa.patch
application/octet-stream
Filename: v31-0008-Don-t-copy-PartitionBoundInfo-in-set_relation_pa.patch
Type: application/octet-stream
Part: 7
Patch
Format: format-patch
Series: patch v31-0008
Subject: Don't copy PartitionBoundInfo in set_relation_partition_info
| File | + | − |
|---|---|---|
| src/backend/optimizer/util/plancat.c | 7 | 3 |
From 89238adde5620ada0a895e6842197f8e3c8871e7 Mon Sep 17 00:00:00 2001
From: amit <amitlangote09@gmail.com>
Date: Mon, 4 Mar 2019 16:03:49 +0900
Subject: [PATCH v31 8/8] 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 | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 2b22dff690..b8f01269be 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -2082,13 +2082,11 @@ set_relation_partition_info(PlannerInfo *root, RelOptInfo *rel,
Relation relation)
{
PartitionDesc partdesc;
- PartitionKey partkey;
Assert(relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
partdesc = PartitionDirectoryLookup(root->glob->partition_directory,
relation);
- partkey = RelationGetPartitionKey(relation);
rel->part_scheme = find_partition_scheme(root, relation);
Assert(partdesc != NULL && rel->part_scheme != NULL);
/*
@@ -2098,7 +2096,13 @@ set_relation_partition_info(PlannerInfo *root, RelOptInfo *rel,
* only lazily updated as far as dropped partitions are concerned.
*/
if (partdesc->nparts > 0)
- rel->boundinfo = partition_bounds_copy(partdesc->boundinfo, partkey);
+ {
+ /*
+ * 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.
+ */
+ rel->boundinfo = partdesc->boundinfo;
+ }
rel->nparts = partdesc->nparts;
set_baserel_partition_key_exprs(relation, rel);
rel->partition_qual = RelationGetPartitionQual(relation);
--
2.17.2 (Apple Git-113)