简体   繁体   English

PostgreSQL WAL 获取提交内容

[英]PostgreSQL WAL get commit content

I'm using PostgreSQL 14.2 and am trying to replicate the inserts/updates/deletes for a database.我正在使用 PostgreSQL 14.2 并尝试复制数据库的插入/更新/删除。 Using使用

pg_waldump --rmgr=Transaction 000000010000000000000001

returns all transactions and I can see my commits, for example:返回所有事务,我可以看到我的提交,例如:

rmgr: Transaction len (rec/tot):     34/    34, tx:        742, lsn: 0/0171DF08, prev 0/0171DE70, desc: ABORT 2022-10-05 08:50:55.236768 UTC
rmgr: Transaction len (rec/tot):     34/    34, tx:        743, lsn: 0/0171E048, prev 0/0171DFA8, desc: COMMIT 2022-10-05 08:51:07.259488 UTC

I would like to access the contents of this commit, for example INSERT INTO table1 VALUES (5, 6);我想访问此提交的内容,例如INSERT INTO table1 VALUES (5, 6); . . Is there a way to access this?有没有办法访问这个?

The WAL level is set to replica . WAL 级别设置为replica Or is the only way to do this by setting the level to logical and then using one of the logical decoding plugins , such as wal2json?或者是通过将级别设置为logical然后使用逻辑解码插件之一(例如 wal2json)来执行此操作的唯一方法? If the level needs to be set to logical , how much would that increase the space of WALs?如果级别需要设置为logical ,那么 WAL 的空间会增加多少?

WAL does not contain logical information (SQL statements), but which bytes in which block of which table is modified. WAL 不包含逻辑信息(SQL 语句),而是修改了哪个表的哪个块中的哪些字节。 You need logical decoding.你需要逻辑解码。 How much more WAL you get when you set wal_level = logical depend on your workload and your table definitions.当您设置wal_level = logical时,您获得多少 WAL 取决于您的工作负载和您的表定义。 You'll have to try it.你必须尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM