Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd637a89

Browse files
committed
Further twiddling of nodeHash.c hashtable sizing calculation.
On reflection, the submitted patch didn't really work to prevent therequest size from exceeding MaxAllocSize, because of the fact that we'dhappily round nbuckets up to the next power of 2 after we'd limited it tomax_pointers. The simplest way to enforce the limit correctly is toround max_pointers down to a power of 2 when it isn't one already.(Note that the constraint to INT_MAX / 2, if it were doing anything usefulat all, is properly applied after that.)
1 parent2647b24 commitd637a89

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎src/backend/executor/nodeHash.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
396396
longhash_table_bytes;
397397
longskew_table_bytes;
398398
longmax_pointers;
399+
longmppow2;
399400
intnbatch;
400401
intnbuckets;
401402
inti;
@@ -463,7 +464,12 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
463464
*/
464465
max_pointers= (work_mem*1024L) /sizeof(HashJoinTuple);
465466
max_pointers=Min(max_pointers,MaxAllocSize /sizeof(HashJoinTuple));
466-
/* also ensure we avoid integer overflow in nbatch and nbuckets */
467+
/* If max_pointers isn't a power of 2, must round it down to one */
468+
mppow2=1L <<my_log2(max_pointers);
469+
if (max_pointers!=mppow2)
470+
max_pointers=mppow2 /2;
471+
472+
/* Also ensure we avoid integer overflow in nbatch and nbuckets */
467473
/* (this step is redundant given the current value of MaxAllocSize) */
468474
max_pointers=Min(max_pointers,INT_MAX /2);
469475

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp