@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $ PostgreSQL : pgsql / src / backend / executor / nodeHash . c , v 1.96 .2 .2 2005 / 11 / 23 20 : 28 : 04 tgl Exp $
* $ PostgreSQL : pgsql / src / backend / executor / nodeHash . c , v 1.96 .2 .3 2007 / 06 / 01 15 : 58 : 09 tgl Exp $
*
*
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
*/
@ -20,6 +20,7 @@
*/
*/
# include "postgres.h"
# include "postgres.h"
# include "access/hash.h"
# include "executor/execdebug.h"
# include "executor/execdebug.h"
# include "executor/hashjoin.h"
# include "executor/hashjoin.h"
# include "executor/instrument.h"
# include "executor/instrument.h"
@ -713,9 +714,11 @@ ExecHashGetHashValue(HashJoinTable hashtable,
* chains ) , and must only cause the batch number to remain the same or
* chains ) , and must only cause the batch number to remain the same or
* increase . Our algorithm is
* increase . Our algorithm is
* bucketno = hashvalue MOD nbuckets
* bucketno = hashvalue MOD nbuckets
* batchno = ( hashvalue DIV nbuckets ) MOD nbatch
* batchno = hash_uint32 ( hashvalue ) MOD nbatch
* where nbuckets should preferably be prime so that all bits of the
* which gives reasonably independent bucket and batch numbers in the face
* hash value can affect both bucketno and batchno .
* of some rather poorly - implemented hash functions in hashfunc . c . ( This
* will change in PG 8.3 . )
*
* nbuckets doesn ' t change over the course of the join .
* nbuckets doesn ' t change over the course of the join .
*
*
* nbatch is always a power of 2 ; we increase it only by doubling it . This
* nbatch is always a power of 2 ; we increase it only by doubling it . This
@ -734,7 +737,7 @@ ExecHashGetBucketAndBatch(HashJoinTable hashtable,
{
{
* bucketno = hashvalue % nbuckets ;
* bucketno = hashvalue % nbuckets ;
/* since nbatch is a power of 2, can do MOD by masking */
/* since nbatch is a power of 2, can do MOD by masking */
* batchno = ( hashvalue / nbuckets ) & ( nbatch - 1 ) ;
* batchno = hash_uint32 ( hashvalue ) & ( nbatch - 1 ) ;
}
}
else
else
{
{