From: Heikki Linnakangas Date: Fri, 15 Apr 2011 11:57:51 +0000 (+0300) Subject: Reduce the initial size of local lock hash to 16 entries. X-Git-Tag: REL9_1_BETA1~93 X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=4c37c1e3b2a7ba7b5519e5e366720e7444878a78;p=postgresql.git Reduce the initial size of local lock hash to 16 entries. 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. --- diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 3fbe14a4090..e3ad3199c4d 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -346,7 +346,7 @@ InitLocks(void) hash_flags = (HASH_ELEM | HASH_FUNCTION); LockMethodLocalHash = hash_create("LOCALLOCK hash", - 128, + 16, &info, hash_flags); }