]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Rotate instead of shifting hash join batch number.
authorThomas Munro <tmunro@postgresql.org>
Mon, 23 Dec 2019 22:31:24 +0000 (11:31 +1300)
committerThomas Munro <tmunro@postgresql.org>
Tue, 24 Dec 2019 00:07:54 +0000 (13:07 +1300)
commit8052aaf521e4885477bd1af100edcf21031e6d11
treeec03ce1a54a8358c6b742110a5789e1aeda70ab1
parentb5e7569dddd2ef8b3d84b528be916647e7465c12
Rotate instead of shifting hash join batch number.

Our algorithm for choosing batch numbers turned out not to work
effectively for multi-billion key inner relations.  We would use
more hash bits than we have, and effectively concentrate all tuples
into a smaller number of batches than we intended.  While ideally
we should switch to wider hashes, for now, change the algorithm to
one that effectively gives up bits from the bucket number when we
don't have enough bits.  That means we'll finish up with longer
bucket chains than would be ideal, but that's better than having
batches that don't fit in work_mem and can't be divided.

Batch-patch to all supported releases.

Author: Thomas Munro
Reviewed-by: Tom Lane, thanks also to Tomas Vondra, Alvaro Herrera, Andres Freund for testing and discussion
Reported-by: James Coleman
Discussion: https://postgr.es/m/16104-dc11ed911f1ab9df%40postgresql.org
src/backend/executor/nodeHash.c
src/include/port/pg_bitutils.h