Skip to content

Commit fa09f89

Browse files
committed
Clamp adjusted ndistinct to positive integer in estimate_hash_bucketsize().
This avoids a possible divide-by-zero in the following calculation, and rounding the number to an integer seems like saner behavior anyway. Assuming IEEE math, the division would yield +Infinity which would get replaced by 1.0 at the bottom of the function, so nothing really interesting would ensue; but avoiding divide-by-zero seems like a good idea on general principles. Per report from Piotr Stefaniak. No back-patch since this seems mostly cosmetic.
1 parent 408f043 commit fa09f89

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/backend/utils/adt/selfuncs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3541,7 +3541,10 @@ estimate_hash_bucketsize(PlannerInfo *root, Node *hashkey, double nbuckets)
35413541
* selectivity of rel's restriction clauses that mention the target Var.
35423542
*/
35433543
if (vardata.rel)
3544+
{
35443545
ndistinct *= vardata.rel->rows / vardata.rel->tuples;
3546+
ndistinct = clamp_row_est(ndistinct);
3547+
}
35453548

35463549
/*
35473550
* Initial estimate of bucketsize fraction is 1/nbuckets as long as the

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy