0

I've been reading about postgresql replication and was wondering if it was somehow possible to listen to the replication binary log and push that to some tool like sumologic or splunk so that any changes made could be monitored without having to build update triggers on every table. Is this possible?

0

As I understand it, your options depend a bit on a key requirement: Do you need the changes recorded in exact transactional order or not?

If you need them in exact order, then a change table or replication decoding are the two workable options I've heard of. Postgres does not implement incrementally updated materialized views, so that's out.

If you do not need the changes in precise commit order, then you can use an alternative strategy. For tables of interest, include a column that takes an ever-incrementing number. This is first assigned on INSERT (easy) and then you have to manage updates on UPDATE (harder.) From there, you have a number line that you can select from. If you track the last number you processed, you can then grab everything > than that, and how you have your unprocessed rows. The primary advantage of such a solution is that you can use that same number line to track different rollups, etc.

Logical decoding is probably going to be simplest.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.