Re: BUG #14932: SELECT DISTINCT val FROM table gets stuck in an infinite loop
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: "Todd A. Cook" <tcook@blackducksoftware.com>, pgsql-bugs@postgresql.org,
Andres Freund <andres@anarazel.de>
Date: 2018-01-26T23:22:26Z
Lists: pgsql-bugs
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes: > I suspect you're right the hash is biased to lohalf bits, as you wrote > in the 19/12 message. I don't see any bias in what it's doing, which is basically xoring the two halves and hashing the result. It's possible though that Todd's data set contains values in which corresponding bits of the high and low halves are correlated somehow, in which case the xor would produce a lot of cancellation and a relatively small number of distinct outputs. If we weren't bound by backwards compatibility, we could consider changing to logic more like "if the value is within the int4 range, apply int4hash, otherwise hash all 8 bytes normally". But I don't see how we can change that now that hash indexes are first-class citizens. In any case, we still need a fix for the behavior that the hash table size is blown out by lots of collisions, because that can happen no matter what the hash function is. Andres seems to have dropped the ball on doing something about that. regards, tom lane
Commits
-
Improve bit perturbation in TupleHashTableHash.
- d18d4bca81f8 10.2 landed
- c068f87723ca 11.0 landed
-
Prevent growth of simplehash tables when they're "too empty".
- d1aac2998789 10.2 landed
- ab9f2c429d8f 11.0 landed
-
Add stack-overflow guards in set-operation planning.
- 1b2a3860d3ea 10.2 cited