Updated on 2023-04-19 GMT+08:00

PG_STAT_LAST_OPERATION

PG_STAT_LAST_OPERATION records information about the last DDL execution on database objects, such as tables, views, and functions. This system catalog is supported only by clusters of version 8.2.0.100 or later.

Table 1 PG_STAT_LAST_OPERATION columns

Name

Type

Reference

Description

oid

oid

-

Row identifier (hidden attribute; displayed only when explicitly selected)

classid

oid

-

OID of the system catalog that contains the object

objid

oid

-

OID of the object in its system catalog

staactionname

name

-

Name of the operation taken on an object

stasysid

oid

PG_AUTHID.oid

OID of the DDL operation implementer

statime

timestamp with time zone

-

Timestamp of the DDL operation

csn

xid

-

CSN that is not pushed when the DDL operation is executed

stasubtype

text

-

Type of the object on which the operation is performed, or the subclass of the operation

Examples

Check information about the last DDL executed on a table.

1
2
3
4
5
6
SELECT * FROM PG_STAT_LAST_OPERATION;
 classid | objid | staactionname | stasysid |            statime            |   csn   | stasubtype
---------+-------+---------------+----------+-------------------------------+---------+-------------
    1259 | 20163 | CREATE        |       10 | 2023-01-04 14:37:31.477995+08 |  282450 | TABLE
    1259 | 20163 | VACUUM        |       10 | 2023-01-05 18:03:19.579291+08 | 1282717 | VACUUM FULL
(2 rows)