Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse postgresql wal log file to sql

Tags:

postgresql

wal

The PostgreSQL database server stores "change data" in WAL log file, and I wanted to parse the archive log file to sql like mysqlbinlog parse binlog file to sql, That I can find the application execute sql. Does anyone have a tool like this?

like image 838
user3007747 Avatar asked Nov 19 '13 07:11

user3007747


People also ask

What is WAL files in PostgreSQL?

WAL is short for Write Ahead Log. WALs are used in nearly all modern RDBMS systems to provide durable and atomic transactions. Simply put, any transaction performed on the database is first written out as a WAL file, then applied to the actual on-disk table data files. WAL files are strictly sequential.

How do I clean up PostgreSQL WAL files?

You can use the pg_archivecleanup command to remove WAL from an archive (not pg_xlog ) that's not required by a given base backup. In general I suggest using PgBarman or a similar tool to automate your base backups and WAL retention though.

What is WAL buffer in PostgreSQL?

WAL Buffers The write ahead log (WAL) buffers are also called "transaction log buffers", which is an amount of memory allocation for storing WAL data. This WAL data is the metadata information about changes to the actual data, and is sufficient to reconstruct actual data during database recovery operations.


2 Answers

You can't. It's the changes to the actual disk blocks.

You can set the server to log all the SQL statements to file if you would like though. Not sure you'd be able to replay them without being very clear about transaction boundaries though.

like image 137
Richard Huxton Avatar answered Sep 28 '22 01:09

Richard Huxton


This feature is currently under development. (Look for "logical replication" patches by Andres Freund.) It's a huge project, so don't hold your breath. The short answer is: It's currently not possible.

like image 32
Peter Eisentraut Avatar answered Sep 28 '22 02:09

Peter Eisentraut