One of the really cool things I learned at this year’s PostgreSQL@SCaLE event was the new push of the PostgreSQL driver developers to integrate support for the PostgreSQL replication protocol. Dave Cramer first talked about in his JDBC talk and after talking to others, I found out the latest version of PsycoPG also has replication support.

This is really exciting for any application that needs to track changes in the database for whatever reason. You can now have a Java or Python service that listens for changes to the database and does things like invalidate cache entries. You really don’t even need to clear the cache entry. You have all of the data to potentially just update.

When you combine the drivers with a cool logical decoding plug-in like wal2json you get all of the changes to the database in a nice handy JSON document. The updates even include the new and old values. The more I think of the possible uses for this plumbing now being in place, the more cool things I can think to do with it.

Sure, we were able to do these things with triggers in the past, but now there is essentially no overhead to capture changes to your database. Triggers have a pretty substantial overhead so you shouldn’t use them often.

This new, simple to use, flexible and lightweight form of change data capture for PostgreSQL can really be the next game changer.