Index: doc/src/sgml/monitoring.sgml =================================================================== RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/monitoring.sgml,v retrieving revision 1.10 diff -c -r1.10 monitoring.sgml *** doc/src/sgml/monitoring.sgml 4 Aug 2002 19:51:30 -0000 1.10 --- doc/src/sgml/monitoring.sgml 14 Aug 2002 02:09:18 -0000 *************** *** 543,548 **** --- 543,676 ---- + + + Viewing Locks + + + Another useful tool for monitoring database activity is the + pg_locks system catalog. This allows the + database administrator to view information about the outstanding + locks in the lock manager. For example, this capability can be + used to: + + + + View all the locks currently outstanding, all the locks on + relations in a particular database, all the locks on a + particular relation, or all the locks held by a particular + PostgreSQL backend. + + + + + View the relation in the current database with the most + un-granted locks (which might be a source of contention among + database clients). + + + + + Determine the effect of lock contention on overall database + performance, as well as the extent to which contention varies + with overall database traffic. + + + + + For more information on locking and managing concurrency with + PostgreSQL, refer to the + Administrator's Guide. + + + + + When the pg_locks view is accessed, an + exclusive lock on an internal lock manager data structure must be + acquired to ensure that the data produced by the view is + consistent. The lock held on this structure conflicts with normal + database operations, and can therefore have an effect on overall + database performance. Nevertheless, the performance impact of + accessing this view should be minimal in most situations. + + + + + The pg_locks view contains one row per + lock. This means that if there are multiple locks on a single + relation (which may or may not conflict with one another), a + single relation may show up many times. Furthermore, only + table-level locks are displayed (not row-level ones). + + + + Lock Status System View + + + + + Column Name + Type + Description + + + + + + relation + oid + The OID of the locked relation. When querying + pg_locks, this column can be joined with the + pg_class system catalog to get more + information on the locked relation. + + + + database + oid + The OID of the database in which the locked relation + exists. If the lock is on a globally-shared object, this value + will be 0. When querying pg_locks, this + column can be joined with the pg_database + system catalog to get more information on the locked object's + database. + + + + backendpid + int4 + The process ID of the + PostgreSQL backend that has + acquired or is attempting to acquire the lock. If you have + enabled the statistics collector, this column can be joined + with the pg_stat_activity view to access + more information on the backend holding or waiting to hold the + lock. + + + + mode + text + The mode of the lock. For more information on the + different lock modes available in + PostgreSQL, refer to the + User's Guide. + + + + isgranted + text + A boolean column indicating whether or not this + particular lock has been granted. If the lock has not been + granted, the backend atempting to acquire it will sleep until + the lock is released (or a deadlock situation is detected). A + single backend can be waiting to acquire at most one lock at + any given time. + + + +
+