mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
Marginal hack to avoid spending a lot of time in find_join_rel during
large planning problems: when the list of join rels gets too long, make an auxiliary hash table that hashes on the identifying Bitmapset.
This commit is contained in:
@ -14,7 +14,7 @@
|
||||
* Copyright (c) 2003-2005, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/bitmapset.c,v 1.7 2005/01/01 20:44:15 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/nodes/bitmapset.c,v 1.8 2005/06/08 23:02:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -763,3 +763,28 @@ bms_first_member(Bitmapset *a)
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* bms_hash_value - compute a hash key for a Bitmapset
|
||||
*
|
||||
* Note: we must ensure that any two bitmapsets that are bms_equal() will
|
||||
* hash to the same value; in practice this means that trailing all-zero
|
||||
* words cannot affect the result. Longitudinal XOR provides a reasonable
|
||||
* hash value that has this property.
|
||||
*/
|
||||
uint32
|
||||
bms_hash_value(const Bitmapset *a)
|
||||
{
|
||||
bitmapword result = 0;
|
||||
int nwords;
|
||||
int wordnum;
|
||||
|
||||
if (a == NULL)
|
||||
return 0; /* All empty sets hash to 0 */
|
||||
nwords = a->nwords;
|
||||
for (wordnum = 0; wordnum < nwords; wordnum++)
|
||||
{
|
||||
result ^= a->words[wordnum];
|
||||
}
|
||||
return (uint32) result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user