]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Remove 10% safety margin from lock manager hash table estimates
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 3 Apr 2026 17:26:18 +0000 (20:26 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Fri, 3 Apr 2026 17:26:18 +0000 (20:26 +0300)
As the comment says, the hash table sizes are just estimates, but that
doesn't mean we need a "safety margin" here. hash_estimate_size()
estimates the needed size in bytes pretty accurately for the given
number of elements, so if we wanted room for more elements in the
table, we should just use larger max_table_size in the
hash_estimate_size() call.

Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres@gmail.com>
Discussion: https://www.postgresql.org/message-id/e07be2ba-856b-4ff5-8313-8b58b6b4e4d0@iki.fi

src/backend/storage/lmgr/lock.c

index 234643e4dd7a335c0468b8af66559da5d1cbba75..2159de9015a1fab66baa57fb47a0ebcde564898e 100644 (file)
@@ -3778,11 +3778,6 @@ LockManagerShmemSize(void)
        max_table_size *= 2;
        size = add_size(size, hash_estimate_size(max_table_size, sizeof(PROCLOCK)));
 
-       /*
-        * Since NLOCKENTS is only an estimate, add 10% safety margin.
-        */
-       size = add_size(size, size / 10);
-
        return size;
 }