summaryrefslogtreecommitdiff
path: root/src/backend/utils/hash
diff options
context:
space:
mode:
authorTom Lane2005-06-08 23:02:05 +0000
committerTom Lane2005-06-08 23:02:05 +0000
commite3a33a9a9f1a6afb80c9b83c1456c1a36fbcb70b (patch)
tree9dc1b4c1acb8e24ecf82dc2536bdcc85c48774b0 /src/backend/utils/hash
parent77c168a836e4bec87461107a84d7b7bcf2b58156 (diff)
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/utils/hash')
-rw-r--r--src/backend/utils/hash/hashfn.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c
index 24255f31e6e..c5968658161 100644
--- a/src/backend/utils/hash/hashfn.c
+++ b/src/backend/utils/hash/hashfn.c
@@ -9,13 +9,14 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.23 2005/04/14 20:32:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/hash/hashfn.c,v 1.24 2005/06/08 23:02:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include "access/hash.h"
+#include "nodes/bitmapset.h"
#include "utils/hsearch.h"
@@ -53,3 +54,26 @@ oid_hash(const void *key, Size keysize)
/* We don't actually bother to do anything to the OID value ... */
return (uint32) *((const Oid *) key);
}
+
+/*
+ * bitmap_hash: hash function for keys that are (pointers to) Bitmapsets
+ *
+ * Note: don't forget to specify bitmap_match as the match function!
+ */
+uint32
+bitmap_hash(const void *key, Size keysize)
+{
+ Assert(keysize == sizeof(Bitmapset *));
+ return bms_hash_value(*((const Bitmapset * const *) key));
+}
+
+/*
+ * bitmap_match: match function to use with bitmap_hash
+ */
+int
+bitmap_match(const void *key1, const void *key2, Size keysize)
+{
+ Assert(keysize == sizeof(Bitmapset *));
+ return !bms_equal(*((const Bitmapset * const *) key1),
+ *((const Bitmapset * const *) key2));
+}