Re: BUG #16104: Invalid DSA Memory Alloc Request in Parallel Hash
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Andres Freund <andres@anarazel.de>, James Coleman <jtc331@gmail.com>, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Date: 2019-11-11T00:33:41Z
Lists: pgsql-bugs
Attachments
- rehash-partition.patch (application/octet-stream) patch
On Mon, Nov 11, 2019 at 12:44 PM Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote: > On Sun, Nov 10, 2019 at 02:46:31PM -0800, Andres Freund wrote: > >On 2019-11-10 22:50:17 +0100, Tomas Vondra wrote: > >> On Sun, Nov 10, 2019 at 10:23:52PM +0100, Tomas Vondra wrote: > >> > On Mon, Nov 11, 2019 at 10:08:58AM +1300, Thomas Munro wrote: > >> > Can't we simply compute two hash values, using different seeds - one for > >> > bucket and the other for batch? Of course, that'll be more expensive. > >> > >> Meh, I realized that's pretty much just a different way to get 64-bit > >> hashes (which is what you mentioned). > > > >I'm not sure it's really the same, given practical realities in > >postgres. Right now the "extended" hash function supporting 64 bit hash > >functions is optional. So we couldn't unconditionally rely on it being > >present, even in master, unless we're prepared to declare it as > >required from now on. > > > >So computing two different hash values at the same time, by using a > >different IV and a different combine function, doesn't seem like an > >unreasonable approach. > > True. I was commenting on the theoretical fact that computing two 32-bit > hashes is close to computing a 64-bit hash, but you're right there are > implementation details that may make it more usable in our case. Here is a quick sketch of something like that, for discussion only. I figured that simply mixing the hash value we have with some arbitrary bits afterwards would be just as good as having started with a different IV, which leads to a very simple change without refactoring. >From quick experiments with unique keys (generate_series) I seem to get approximately even sized partitions, and correct answers, but I make no claim to strong hash-math-fu and haven't tested on very large inputs. Thoughts?
Commits
-
Rotate instead of shifting hash join batch number.
- 5c0a132cf141 9.4.26 landed
- 893eaf0be8be 9.5.21 landed
- 15861deb65cd 9.6.17 landed
- 8e89bc6dfd3d 10.12 landed
- 9e551a14cb45 11.7 landed
- 8052aaf521e4 12.2 landed
- e69d64454778 13.0 landed