PostgreSQL 18 ← 17
SYSTEM VIEW · 系统视图
pg_locks
The view pg_locks provides access to information about the locks held by active processes within the database server. See Chapter 13 for more discussion of locking. pg_locks contains one row per active lockable object, requested lock mode, and relevant process. Thus, the same lockable object might appear many times, if multiple processes are holding or waiting for locks on it. However, an object that currently has no locks on it will not appear at all. There are several distinct types of lockable objects: whole relations (e.g., tables), individual pages of relations, individual tuples of relations, transaction IDs (both virtual and permanent IDs), and general database objects (identified by class OID and object OID, in the same way as in pg_description or pg_depend). Also, the right to extend a relation is represented as a separate lockable object, as is the right to update pg_database.datfrozenxid. Also, “advisory” locks can be taken on numbers that have user-defined meanings.
已与 PostgreSQL 18.6 实例逐字段核对 · 原始实测记录 ↗
字段结构 PostgreSQL 18
pg_locks| 字段 / COLUMN | 类型 / TYPE | 说明 / DESCRIPTION |
|---|---|---|
locktype |
text |
Type of the lockable object: relation, extend, frozenid, page, tuple, transactionid, virtualxid, spectoken, object, userlock, advisory, or applytransaction. (See also Table 27.11.) |
database |
oid |
OID 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 |
relation |
oid |
OID of the relation targeted by the lock, or null if the target is not a relation or part of a relation引用:pg_class.oid |
page |
integer文档原写法:int4 |
Page number targeted by the lock within the relation, or null if the target is not a relation page or tuple |
tuple |
smallint文档原写法:int2 |
Tuple number targeted by the lock within the page, or null if the target is not a tuple |
virtualxid |
text |
Virtual ID of the transaction targeted by the lock, or null if the target is not a virtual transaction ID; see Chapter 67 |
transactionid |
xid |
ID of the transaction targeted by the lock, or null if the target is not a transaction ID; Chapter 67 |
classid |
oid |
OID of the system catalog containing the lock target, or null if the target is not a general database object引用:pg_class.oid |
objid |
oid |
OID of the lock target within its system catalog, or null if the target is not a general database object引用:any OID column |
objsubid |
smallint文档原写法:int2 |
Column 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 |
virtualtransaction |
text |
Virtual ID of the transaction that is holding or awaiting this lock |
pid |
integer文档原写法:int4 |
Process ID of the server process holding or awaiting this lock, or null if the lock is held by a prepared transaction |
mode |
text |
Name of the lock mode held or desired by this process (see Section 13.3.1 and Section 13.2.3) |
granted |
boolean文档原写法:bool |
True if lock is held, false if lock is awaited |
fastpath |
boolean文档原写法:bool |
True if lock was taken via fast path, false if taken via main lock table |
waitstart |
timestamp with time zone文档原写法:timestamptz |
Time 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. |
标记“隐式列”的字段不包含在 SELECT * 中;部分早期统计视图由同版本源码补全,额外来源会显示在字段说明中。
通用系统列 0
PostgreSQL 提供的系统属性,通常不在 SELECT * 中展开。单独保留,不与普通字段混算。
| 字段 | 类型 | attnum |
|---|
字段演化矩阵
悬停查看字段类型9.0 是收录基线;基线中已存在的字段不标记为新增。矩阵按字段名称对齐,重命名显示为旧字段移除与新字段新增。
演化时间线
相邻大版本的变化PostgreSQL 17 ← 16
PostgreSQL 16 ← 15
PostgreSQL 14 ← 13
PostgreSQL 13 ← 12
PostgreSQL 10 ← 9.6
PostgreSQL 9.6 ← 9.5
PostgreSQL 9.5 ← 9.4
PostgreSQL 9.2 ← 9.1
PostgreSQL 9.1 ← 9.0
比较任意两个版本
选择两个版本,查看字段的新增、移除与类型变化。交互比较需要 JavaScript;演化时间线可直接阅读。