summaryrefslogtreecommitdiff
path: root/src/backend/utils/hash
diff options
context:
space:
mode:
authorThomas Munro2020-08-01 00:16:15 +0000
committerThomas Munro2020-08-01 00:16:15 +0000
commit84c0e4b9bce794da914fe9c062753bf21369745f (patch)
tree67e2fa3533e5d38527ae5346638e7c910943a379 /src/backend/utils/hash
parentc79aed4f793086300abfc188def94b5c0bd0b45d (diff)
Improve programmer docs for simplehash and dynahash.
When reading the code it's not obvious when one should prefer dynahash over simplehash and vice-versa, so, for programmer-friendliness, add comments to inform that decision. Show sample simplehash method signatures. Author: James Coleman <[email protected]> Discussion: https://postgr.es/m/CAAaqYe_dOF39gAJ8rL-a3YO3Qo96MHMRQ2whFjK5ZcU6YvMQSA%40mail.gmail.com
Diffstat (limited to 'src/backend/utils/hash')
-rw-r--r--src/backend/utils/hash/dynahash.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c
index 5948b01abc3..f4fbccdd7e4 100644
--- a/src/backend/utils/hash/dynahash.c
+++ b/src/backend/utils/hash/dynahash.c
@@ -1,7 +1,7 @@
/*-------------------------------------------------------------------------
*
* dynahash.c
- * dynamic hash tables
+ * dynamic chained hash tables
*
* dynahash.c supports both local-to-a-backend hash tables and hash tables in
* shared memory. For shared hash tables, it is the caller's responsibility
@@ -41,6 +41,16 @@
* function must be supplied; comparison defaults to memcmp() and key copying
* to memcpy() when a user-defined hashing function is selected.
*
+ * Compared to simplehash, dynahash has the following benefits:
+ *
+ * - It supports partitioning, which is useful for shared memory access using
+ * locks.
+ * - Shared memory hashes are allocated in a fixed size area at startup and
+ * are discoverable by name from other processes.
+ * - Because entries don't need to be moved in the case of hash conflicts, has
+ * better performance for large entries
+ * - Guarantees stable pointers to entries.
+ *
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*