summaryrefslogtreecommitdiff
path: root/src/backend/storage/lmgr/lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/lmgr/lock.c')
-rw-r--r--src/backend/storage/lmgr/lock.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 002303664aa..86b06b9223f 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -210,9 +210,12 @@ int FastPathLockGroupsPerBackend = 0;
*
* The selected constant (49157) is a prime not too close to 2^k, and it's
* small enough to not cause overflows (in 64-bit).
+ *
+ * We can assume that FastPathLockGroupsPerBackend is a power-of-two per
+ * InitializeFastPathLocks().
*/
#define FAST_PATH_REL_GROUP(rel) \
- (((uint64) (rel) * 49157) % FastPathLockGroupsPerBackend)
+ (((uint64) (rel) * 49157) & (FastPathLockGroupsPerBackend - 1))
/*
* Given the group/slot indexes, calculate the slot index in the whole array