3 ms·
You can do that with PostgreSQL logical decoding, which listens to the replication stream. You can write a plugin in C to emit the updates in whatever form you
by fanf2 8y ago
You can do that with PostgreSQL logical decoding, which listens to the replication stream. You can write a plugin in C to emit the updates in whatever form you need.
- andy_ppp 8y agoWhy do you need to do that... https://www.postgresql.org/docs/9.0/sql-notify.html https://www.postgresql.org/docs/9.0/sql-notify.html Should be okay for 99% of needs no?
- alecbenzer 8y agoThat sounds like you'd need to manually enumerate all possible queries you'd want to listen to and have all writers do the work of deciding which channels to update. The idea of simply being able to listen to a query without any additional work sounds like it could be really attractive in certain situations.
- andy_ppp 8y ago"The idea of simply being able to listen to a query without any additional work sounds like it could be really attractive in certain situations." Sounds a lot like RethinkDB changefeeds https://rethinkdb.com/docs/changefeeds/ https://rethinkdb.com/docs/changefeeds/ maybe check that out first :^)
- virgilp 8y agoRight; but you have to implement it yourself, and you'll know the limitations (e.g. it'll probably be expensive to notify on changes to complex queries and/or on many queries).
- pritambaral 8y agoI actually implemented this (i.e, your parent's idea) for a product. Took me an afternoon to read the documentation and source of the logical output plugin and build a logical replication receiver (using the guts of an existing binary-protocol driver). Of course, that is a testament to the quality of the documentation and the source code of PostgreSQL. The fact that the Logical Decoding and Logical Output features were built for replication means that some decisions were taken not-in-favour of publishing changes, obviously, but it works pleasantly and straightforwardly. Even writing a custom logical output plugin would be simple, because Pg does all the transaction tracking, position tracking, change decoding etc.