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

Commit4075fc4

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 parentff4cbc1 commit4075fc4

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
@@ -397,6 +397,7 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
397397
longhash_table_bytes;
398398
longskew_table_bytes;
399399
longmax_pointers;
400+
longmppow2;
400401
intnbatch;
401402
intnbuckets;
402403
inti;
@@ -464,7 +465,12 @@ ExecChooseHashTableSize(double ntuples, int tupwidth, bool useskew,
464465
*/
465466
max_pointers= (work_mem*1024L) /sizeof(HashJoinTuple);
466467
max_pointers=Min(max_pointers,MaxAllocSize /sizeof(HashJoinTuple));
467-
/* also ensure we avoid integer overflow in nbatch and nbuckets */
468+
/* If max_pointers isn't a power of 2, must round it down to one */
469+
mppow2=1L <<my_log2(max_pointers);
470+
if (max_pointers!=mppow2)
471+
max_pointers=mppow2 /2;
472+
473+
/* Also ensure we avoid integer overflow in nbatch and nbuckets */
468474
/* (this step is redundant given the current value of MaxAllocSize) */
469475
max_pointers=Min(max_pointers,INT_MAX /2);
470476

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp