pg_locks
pg_locks
is a system catalogue view listing the locks held by active processes.
pg_locks
was added in PostgreSQL 7.3.
Definition by PostgreSQL version
pg_locks (PostgreSQL 16)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+--------------------------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | | waitstart | timestamp with time zone | | |
Documentation: pg_locks
pg_locks (PostgreSQL 15)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+--------------------------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | | waitstart | timestamp with time zone | | |
Documentation: pg_locks
pg_locks (PostgreSQL 14)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+--------------------------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | | waitstart | timestamp with time zone | | |
Documentation: pg_locks
pg_locks (PostgreSQL 13)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+----------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | |
Documentation: pg_locks
pg_locks (PostgreSQL 12)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+----------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | |
Documentation: pg_locks
pg_locks (PostgreSQL 11)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+----------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | |
Documentation: pg_locks
pg_locks (PostgreSQL 10)
View "pg_catalog.pg_locks" Column | Type | Collation | Nullable | Default --------------------+----------+-----------+----------+--------- locktype | text | | | database | oid | | | relation | oid | | | page | integer | | | tuple | smallint | | | virtualxid | text | | | transactionid | xid | | | classid | oid | | | objid | oid | | | objsubid | smallint | | | virtualtransaction | text | | | pid | integer | | | mode | text | | | granted | boolean | | | fastpath | boolean | | |
Documentation: pg_locks
pg_locks (PostgreSQL 9.6)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | fastpath | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.5)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | fastpath | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.4)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | fastpath | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.3)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | fastpath | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.2)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | fastpath | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.1)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 9.0)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean |
Documentation: pg_locks
pg_locks (PostgreSQL 8.4)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | View definition: SELECT l.locktype, l.database, l.relation, l.page, l.tuple, l.virtualxid, l.transactionid, l.classid, l.objid, l.objsubid, l.virtualtransaction, l.pid, l.mode, l.granted FROM pg_lock_status() l(locktype, database, relation, page, tuple, virtualxid, transactionid, classid, objid, objsubid, virtualtransaction, pid, mode, granted);
Documentation: pg_locks
pg_locks (PostgreSQL 8.3)
View "pg_catalog.pg_locks" Column | Type | Modifiers --------------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | virtualxid | text | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | virtualtransaction | text | pid | integer | mode | text | granted | boolean | View definition: SELECT l.locktype, l.database, l.relation, l.page, l.tuple, l.virtualxid, l.transactionid, l.classid, l.objid, l.objsubid, l.virtualtransaction, l.pid, l.mode, l.granted FROM pg_lock_status() l(locktype text, database oid, relation oid, page integer, tuple smallint, virtualxid text, transactionid xid, classid oid, objid oid, objsubid smallint, virtualtransaction text, pid integer, mode text, granted boolean);
Documentation: pg_locks
pg_locks (PostgreSQL 8.2)
View "pg_catalog.pg_locks" Column | Type | Modifiers ---------------+----------+----------- locktype | text | database | oid | relation | oid | page | integer | tuple | smallint | transactionid | xid | classid | oid | objid | oid | objsubid | smallint | transaction | xid | pid | integer | mode | text | granted | boolean | View definition: SELECT l.locktype, l."database", l.relation, l.page, l.tuple, l.transactionid, l.classid, l.objid, l.objsubid, l."transaction", l.pid, l."mode", l."granted" FROM pg_lock_status() l(locktype text, "database" oid, relation oid, page integer, tuple smallint, transactionid xid, classid oid, objid oid, objsubid smallint, "transaction" xid, pid integer, "mode" text, "granted" boolean);
Documentation: pg_locks
Change history
- PostgreSQL 14
- column
waitstart
added (commit 46d6e5f5)
- column
- PostgreSQL 9.2
- column
fastpath
added (commit 3cba8999)
- column
- PostgreSQL 8.3
- PostgreSQL 8.1
- PostgreSQL 7.3
- added (commit 82119a69).
Examples
Sample row from pg_locks
:
postgres=# SELECT * FROM pg_locks WHERE relation = 'foo'::regclass; -[ RECORD 1 ]------+-------------------- locktype | relation database | 5 relation | 16425 page | tuple | virtualxid | transactionid | classid | objid | objsubid | virtualtransaction | 6/84 pid | 783970 mode | AccessExclusiveLock granted | t fastpath | f waitstart |
References
- PostgreSQL dcumentation: pg_locks