diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-08 23:02:05 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-06-08 23:02:05 +0000 |
commit | e3a33a9a9f1a6afb80c9b83c1456c1a36fbcb70b (patch) | |
tree | 9dc1b4c1acb8e24ecf82dc2536bdcc85c48774b0 /src/backend/nodes/bitmapset.c | |
parent | 77c168a836e4bec87461107a84d7b7bcf2b58156 (diff) | |
download | postgresql-e3a33a9a9f1a6afb80c9b83c1456c1a36fbcb70b.tar.gz postgresql-e3a33a9a9f1a6afb80c9b83c1456c1a36fbcb70b.zip |
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.
Diffstat (limited to 'src/backend/nodes/bitmapset.c')
-rw-r--r-- | src/backend/nodes/bitmapset.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/backend/nodes/bitmapset.c b/src/backend/nodes/bitmapset.c index 699f0439ffc..5f4ca9a779b 100644 --- a/src/backend/nodes/bitmapset.c +++ b/src/backend/nodes/bitmapset.c @@ -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; +} |