1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-09 22:41:56 +03:00

Modify additional power 2 calculations to use new helper functions

2nd pass of modifying various places which obtain the next power
of 2 of a number and make them use the new functions added in
f0705bb62.

In passing, also modify num_combinations(). This can be implemented
using simple bitshifting rather than looping.

Reviewed-by: John Naylor
Discussion: https://postgr.es/m/20200114173553.GE32763%40fetter.org
This commit is contained in:
David Rowley
2020-04-08 18:29:51 +12:00
parent c0187869a0
commit 02a2e8b442
5 changed files with 16 additions and 38 deletions

View File

@ -831,9 +831,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
dbatch = ceil(inner_rel_bytes / (hash_table_bytes - bucket_bytes));
dbatch = Min(dbatch, max_pointers);
minbatch = (int) dbatch;
nbatch = 2;
while (nbatch < minbatch)
nbatch <<= 1;
nbatch = pg_nextpower2_32(Max(2, minbatch));
}
Assert(nbuckets > 0);
@ -2272,9 +2270,7 @@ ExecHashBuildSkewHash(HashJoinTable hashtable, Hash *node, int mcvsToUse)
* MaxAllocSize/sizeof(void *)/8, but that is not currently possible
* since we limit pg_statistic entries to much less than that.
*/
nbuckets = 2;
while (nbuckets <= mcvsToUse)
nbuckets <<= 1;
nbuckets = pg_nextpower2_32(mcvsToUse + 1);
/* use two more bits just to help avoid collisions */
nbuckets <<= 2;