mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Avoid redundant checks in partition_bounds_copy().
Previously, partition_bounds_copy() checked whether the strategy for the given partition bounds was hash or not, and then determined the number of elements in the datums in the datums array for the partition bounds, on each iteration of the loop for copying the datums array, but there is no need to do that. Perform the checks only once before the loop iteration. Author: Etsuro Fujita Reported-by: Amit Langote and Julien Rouhaud Discussion: https://postgr.es/m/CAPmGK14Rvxrm8DHWvCjdoks6nwZuHBPvMnWZ6rkEx2KhFeEoPQ@mail.gmail.com
This commit is contained in:
parent
957338418b
commit
032f9ae012
@ -789,6 +789,8 @@ partition_bounds_copy(PartitionBoundInfo src,
|
|||||||
int ndatums;
|
int ndatums;
|
||||||
int partnatts;
|
int partnatts;
|
||||||
int num_indexes;
|
int num_indexes;
|
||||||
|
bool hash_part;
|
||||||
|
int natts;
|
||||||
|
|
||||||
dest = (PartitionBoundInfo) palloc(sizeof(PartitionBoundInfoData));
|
dest = (PartitionBoundInfo) palloc(sizeof(PartitionBoundInfoData));
|
||||||
|
|
||||||
@ -819,17 +821,17 @@ partition_bounds_copy(PartitionBoundInfo src,
|
|||||||
else
|
else
|
||||||
dest->kind = NULL;
|
dest->kind = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For hash partitioning, datums array will have two elements - modulus and
|
||||||
|
* remainder.
|
||||||
|
*/
|
||||||
|
hash_part = (key->strategy == PARTITION_STRATEGY_HASH);
|
||||||
|
natts = hash_part ? 2 : partnatts;
|
||||||
|
|
||||||
for (i = 0; i < ndatums; i++)
|
for (i = 0; i < ndatums; i++)
|
||||||
{
|
{
|
||||||
int j;
|
int j;
|
||||||
|
|
||||||
/*
|
|
||||||
* For a corresponding hash partition, datums array will have two
|
|
||||||
* elements - modulus and remainder.
|
|
||||||
*/
|
|
||||||
bool hash_part = (key->strategy == PARTITION_STRATEGY_HASH);
|
|
||||||
int natts = hash_part ? 2 : partnatts;
|
|
||||||
|
|
||||||
dest->datums[i] = (Datum *) palloc(sizeof(Datum) * natts);
|
dest->datums[i] = (Datum *) palloc(sizeof(Datum) * natts);
|
||||||
|
|
||||||
for (j = 0; j < natts; j++)
|
for (j = 0; j < natts; j++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user