Reduce the initial size of local lock hash to 16 entries.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 15 Apr 2011 11:57:51 +0000 (14:57 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 15 Apr 2011 12:07:36 +0000 (15:07 +0300)
The hash table is seq scanned at transaction end, to release all locks,
and making the hash table larger than necessary makes that slower. With
very simple queries, that overhead can amount to a few percent of the total
CPU time used.

At the moment, backend startup needs 6 locks, and a simple query with one
table and index needs 3 locks. 16 is enough for even quite complicated
transactions, and it will grow automatically if it fills up.

src/backend/storage/lmgr/lock.c

index 3fbe14a40900550b07c45dfbcab3b57d1d32f870..e3ad3199c4dd3edc4cf51dcfe0bb2080b7f1d1e5 100644 (file)
@@ -346,7 +346,7 @@ InitLocks(void)
    hash_flags = (HASH_ELEM | HASH_FUNCTION);
 
    LockMethodLocalHash = hash_create("LOCALLOCK hash",
-                                     128,
+                                     16,
                                      &info,
                                      hash_flags);
 }