Skip to content

Commit c8151e6

Browse files
committed
Don't copy PartitionBoundInfo in set_relation_partition_info.
I (tgl) remain dubious that it's a good idea for PartitionDirectory to hold a pin on a relcache entry throughout planning, rather than copying the data or using some kind of refcount scheme. However, it's certainly the responsibility of the PartitionDirectory code to ensure that what it's handing back is a stable data structure, not that of its caller. So this is a pretty clear oversight in commit 898e5e3, and one that can cost a lot of performance when there are many partitions. Amit Langote (extracted from a much larger patch set) Discussion: https://postgr.es/m/CA+TgmoY3bRmGB6-DUnoVy5fJoreiBJ43rwMrQRCdPXuKt4Ykaw@mail.gmail.com Discussion: https://postgr.es/m/9d7c5112-cb99-6a47-d3be-cf1ee6862a1d@lab.ntt.co.jp
1 parent b5fd497 commit c8151e6

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "optimizer/optimizer.h"
4040
#include "optimizer/plancat.h"
4141
#include "optimizer/prep.h"
42-
#include "partitioning/partbounds.h"
4342
#include "partitioning/partdesc.h"
4443
#include "parser/parse_relation.h"
4544
#include "parser/parsetree.h"
@@ -2082,16 +2081,14 @@ set_relation_partition_info(PlannerInfo *root, RelOptInfo *rel,
20822081
Relation relation)
20832082
{
20842083
PartitionDesc partdesc;
2085-
PartitionKey partkey;
20862084

20872085
Assert(relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE);
20882086

20892087
partdesc = PartitionDirectoryLookup(root->glob->partition_directory,
20902088
relation);
2091-
partkey = RelationGetPartitionKey(relation);
20922089
rel->part_scheme = find_partition_scheme(root, relation);
20932090
Assert(partdesc != NULL && rel->part_scheme != NULL);
2094-
rel->boundinfo = partition_bounds_copy(partdesc->boundinfo, partkey);
2091+
rel->boundinfo = partdesc->boundinfo;
20952092
rel->nparts = partdesc->nparts;
20962093
set_baserel_partition_key_exprs(relation, rel);
20972094
rel->partition_qual = RelationGetPartitionQual(relation);

0 commit comments

Comments
 (0)