select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SYSTEM CATALOGS / SYSTEM VIEWS

The view pg_locks provides access to information about the locks held by active processes within the database server.

Kind
System views
Columns in this snapshot
16
Definition source
English manual

Columns 16

ColumnTypeDescription / reference
locktypetextType of the lockable object: relation, extend, frozenid, page, tuple, transactionid, virtualxid, spectoken, object, userlock, advisory, or applytransaction. (See also Table 27.11.)
databaseoidOID of the database in which the lock target exists, or zero if the target is a shared object, or null if the target is a transaction ID
pg_database.oid
relationoidOID of the relation targeted by the lock, or null if the target is not a relation or part of a relation
pg_class.oid
pageint4Page number targeted by the lock within the relation, or null if the target is not a relation page or tuple
tupleint2Tuple number targeted by the lock within the page, or null if the target is not a tuple
virtualxidtextVirtual ID of the transaction targeted by the lock, or null if the target is not a virtual transaction ID; see Chapter 67
transactionidxidID of the transaction targeted by the lock, or null if the target is not a transaction ID; Chapter 67
classidoidOID of the system catalog containing the lock target, or null if the target is not a general database object
pg_class.oid
objidoidOID of the lock target within its system catalog, or null if the target is not a general database object
objsubidint2Column number targeted by the lock (the classid and objid refer to the table itself), or zero if the target is some other general database object, or null if the target is not a general database object
virtualtransactiontextVirtual ID of the transaction that is holding or awaiting this lock
pidint4Process ID of the server process holding or awaiting this lock, or null if the lock is held by a prepared transaction
modetextName of the lock mode held or desired by this process (see Section 13.3.1 and Section 13.2.3)
grantedboolTrue if lock is held, false if lock is awaited
fastpathboolTrue if lock was taken via fast path, false if taken via main lock table
waitstarttimestamptzTime when the server process started waiting for this lock, or null if the lock is held. Note that this can be null for a very short period of time after the wait started even though granted is false.
Column history across versions
Version history 11
  1. PG 19 → 20changed
  2. PG 17 → 18changed
  3. PG 16 → 17changed
  4. PG 15 → 16changed
  5. PG 13 → 14changed
  6. PG 12 → 13changed
  7. PG 9.6 → 10changed
  8. PG 9.5 → 9.6changed
  9. PG 9.4 → 9.5changed
  10. PG 9.1 → 9.2changed
  11. PG 9.0 → 9.1changed

Definition snapshot: english-manuals:85c80c6c7d1eb4b87aa5a49fffe… · English manual source