From bd2c980b229eb5cf411b1d55bf9b26cca34875d7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 1 Jun 2007 17:38:44 +0000 Subject: Buy back some of the cycles spent in more-expensive hash functions by selecting power-of-2, rather than prime, numbers of buckets in hash joins. If the hash functions are doing their jobs properly by making all hash bits equally random, this is good enough, and it saves expensive integer division and modulus operations. --- src/include/executor/hashjoin.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/include') diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 19cfb1c473..8056cd88e9 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.44 2007/01/30 01:33:36 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/hashjoin.h,v 1.45 2007/06/01 17:38:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -76,6 +76,8 @@ typedef struct HashJoinTupleData typedef struct HashJoinTableData { int nbuckets; /* # buckets in the in-memory hash table */ + int log2_nbuckets; /* its log2 (nbuckets must be a power of 2) */ + /* buckets[i] is head of list of tuples in i'th in-memory bucket */ struct HashJoinTupleData **buckets; /* buckets array is per-batch storage, as are all the tuples */ -- cgit v1.2.1