Skip to content

Commit 3e32109

Browse files
committed
Use key and partdesc from PartitionDispatch where possible.
Instead of repeatedly fishing the data out of the relcache entry, let's use the version that we cached in the PartitionDispatch. We could alternatively rip out the PartitionDispatch fields altogether, but it doesn't make much sense to have them and not use them; before this patch, partdesc was set but altogether unused. Amit Langote and I both thought using them was a litle better than removing them, so this patch takes that approach. Discussion: http://postgr.es/m/CA+TgmobFnxcaW-Co-XO8=yhJ5pJXoNkCj6Z7jm9Mwj9FGv-D7w@mail.gmail.com
1 parent 8ce29bb commit 3e32109

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/backend/executor/execPartition.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static void FormPartitionKeyDatum(PartitionDispatch pd,
4141
EState *estate,
4242
Datum *values,
4343
bool *isnull);
44-
static int get_partition_for_tuple(Relation relation, Datum *values,
44+
static int get_partition_for_tuple(PartitionDispatch pd, Datum *values,
4545
bool *isnull);
4646
static char *ExecBuildSlotPartitionKeyDescription(Relation rel,
4747
Datum *values,
@@ -208,13 +208,11 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
208208
parent = pd[0];
209209
while (true)
210210
{
211-
PartitionDesc partdesc;
212211
TupleTableSlot *myslot = parent->tupslot;
213212
TupleConversionMap *map = parent->tupmap;
214213
int cur_index = -1;
215214

216215
rel = parent->reldesc;
217-
partdesc = RelationGetPartitionDesc(rel);
218216

219217
/*
220218
* Convert the tuple to this parent's layout so that we can do certain
@@ -245,13 +243,13 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
245243
* Nothing for get_partition_for_tuple() to do if there are no
246244
* partitions to begin with.
247245
*/
248-
if (partdesc->nparts == 0)
246+
if (parent->partdesc->nparts == 0)
249247
{
250248
result = -1;
251249
break;
252250
}
253251

254-
cur_index = get_partition_for_tuple(rel, values, isnull);
252+
cur_index = get_partition_for_tuple(parent, values, isnull);
255253

256254
/*
257255
* cur_index < 0 means we failed to find a partition of this parent.
@@ -1079,12 +1077,12 @@ FormPartitionKeyDatum(PartitionDispatch pd,
10791077
* found or -1 if none found.
10801078
*/
10811079
static int
1082-
get_partition_for_tuple(Relation relation, Datum *values, bool *isnull)
1080+
get_partition_for_tuple(PartitionDispatch pd, Datum *values, bool *isnull)
10831081
{
10841082
int bound_offset;
10851083
int part_index = -1;
1086-
PartitionKey key = RelationGetPartitionKey(relation);
1087-
PartitionDesc partdesc = RelationGetPartitionDesc(relation);
1084+
PartitionKey key = pd->key;
1085+
PartitionDesc partdesc = pd->partdesc;
10881086
PartitionBoundInfo boundinfo = partdesc->boundinfo;
10891087

10901088
/* Route as appropriate based on partitioning strategy. */

0 commit comments

Comments
 (0)