diff options
author | Robert Haas <rhaas@postgresql.org> | 2011-05-28 19:52:00 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2011-07-18 00:49:28 -0400 |
commit | 3cba8999b343648c4c528432ab3d51400194e93b (patch) | |
tree | ef1885a85a6d9b503689235a84d78fbb8c458237 /doc/src | |
parent | 7ed8f6c517ba6bada6bfb9a4dd4216e3b97bc2ba (diff) | |
download | postgresql-3cba8999b343648c4c528432ab3d51400194e93b.tar.gz postgresql-3cba8999b343648c4c528432ab3d51400194e93b.zip |
Create a "fast path" for acquiring weak relation locks.
When an AccessShareLock, RowShareLock, or RowExclusiveLock is requested
on an unshared database relation, and we can verify that no conflicting
locks can possibly be present, record the lock in a per-backend queue,
stored within the PGPROC, rather than in the primary lock table. This
eliminates a great deal of contention on the lock manager LWLocks.
This patch also refactors the interface between GetLockStatusData() and
pg_lock_status() to be a bit more abstract, so that we don't rely so
heavily on the lock manager's internal representation details. The new
fast path lock structures don't have a LOCK or PROCLOCK structure to
return, so we mustn't depend on that for purposes of listing outstanding
locks.
Review by Jeff Davis.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/catalogs.sgml | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 33be5d0979b..0b8602e0e02 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -7040,6 +7040,12 @@ <entry></entry> <entry>True if lock is held, false if lock is awaited</entry> </row> + <row> + <entry><structfield>fastpath</structfield></entry> + <entry><type>boolean</type></entry> + <entry></entry> + <entry>True if lock was taken via fast path, false if taken via main lock table</entry> + </row> </tbody> </tgroup> </table> @@ -7090,16 +7096,29 @@ <para> The <structname>pg_locks</structname> view displays data from both the regular lock manager and the predicate lock manager, which are - separate systems. When this view is accessed, the internal data - structures of each lock manager are momentarily locked, and copies are - made for the view to display. Each lock manager will therefore - produce a consistent set of results, but as we do not lock both lock - managers simultaneously, it is possible for locks to be taken or - released after we interrogate the regular lock manager and before we - interrogate the predicate lock manager. Each lock manager is only - locked for the minimum possible time so as to reduce the performance - impact of querying this view, but there could nevertheless be some - impact on database performance if it is frequently accessed. + separate systems. This data is not guaranteed to be entirely consistent. + Data on fast-path locks (with <structfield>fastpath</> = <literal>true</>) + is gathered from each backend one at a time, without freezing the state of + the entire lock manager, so it is possible for locks to be taken and + released as information is gathered. Note, however, that these locks are + known not to conflict with any other lock currently in place. After + all backends have been queried for fast-path locks, the remainder of the + lock manager is locked as a unit, and a consistent snapshot of all + remaining locks is dumped as an atomic action. Once the lock manager has + been unlocked, the predicate lock manager is similarly locked and all + predicate locks are dumped as an atomic action. Thus, with the exception + of fast-path locks, each lock manager will deliver a consistent set of + results, but as we do not lock both lock managers simultaneously, it is + possible for locks to be taken or released after we interrogate the regular + lock manager and before we interrogate the predicate lock manager. + </para> + + <para> + Locking the lock manger and/or predicate lock manager could have some + impact on database performance if this view is very frequently accessed. + The locks are held only for the minimum amount of time necessary to + obtain data from the lock manager, but this does not completely eliminate + the possibility of a performance impact. </para> <para> |