KingbaseES 开启事务提交跟踪

KingbaseESV8R6有个参数 track_commit_timestamp,用来开启跟踪事务提交的时间戳。

配置
编辑kingbase.conf,添加配置如下:

track_commit_timestamp = on
接着重启kingbase实例。这时候在control file中查看track_commit_timestamp setting: on

查询
使用函数sys_xact_commit_timestamp查询记录更新或插入的时间。如下:

# create table colors (id int,name text);

# INSERT INTO colors VALUES (1,'ga'),(2,'c'),(3,'i');

# SELECT sys_xact_commit_timestamp(xmin), * FROM colors;

test=# SELECT sys_xact_commit_timestamp(xmin), * FROM colors;
   sys_xact_commit_timestamp    | id | name
-------------------------------+----+------
 2022-04-26 10:00:46.692528+08 |  1 | ga
 2022-04-26 10:00:46.692528+08 |  2 | c
 2022-04-26 10:00:46.692528+08 |  3 | i
(3 rows)

需要注意的是,跟踪的时间只对配置参数后并重启数据库实例后新生成的记录有效。

使用sys_last_committed_xact函数查看数据库最后提交事务时间戳:

 # INSERT INTO colors VALUES (7,'l'),(5,'y'),(4,'t');

 # SELECT * FROM sys_last_committed_xact();

 xid |           timestamp
-----+-------------------------------
 944 | 2022-04-26 10:03:59.337716+08
(1 row)


 (1 row)
posted @ 2022-04-28 11:10  KINGBASE研究院  阅读(80)  评论(0编辑  收藏  举报