]> granicus.if.org Git - postgresql/commit
Add a small cache of locks owned by a resource owner in ResourceOwner.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 21 Jun 2012 12:01:17 +0000 (15:01 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 21 Jun 2012 12:30:26 +0000 (15:30 +0300)
commiteeb6f37d89fc60c6449ca12ef9e91491069369cb
tree76e6cabe22e6abf1d080ace54855b45d4e11f42c
parentdfd9c116cc3ebaf42f895b9b16a9ff69bb21664b
Add a small cache of locks owned by a resource owner in ResourceOwner.

This speeds up reassigning locks to the parent owner, when the transaction
holds a lot of locks, but only a few of them belong to the current resource
owner. This is particularly helps pg_dump when dumping a large number of
objects.

The cache can hold up to 15 locks in each resource owner. After that, the
cache is marked as overflowed, and we fall back to the old method of
scanning the whole local lock table. The tradeoff here is that the cache has
to be scanned whenever a lock is released, so if the cache is too large,
lock release becomes more expensive. 15 seems enough to cover pg_dump, and
doesn't have much impact on lock release.

Jeff Janes, reviewed by Amit Kapila and Heikki Linnakangas.
src/backend/storage/lmgr/lock.c
src/backend/utils/resowner/resowner.c
src/include/storage/lock.h
src/include/utils/resowner.h