pg_replicate is a Rust crate to build Postgres logical replication applications

62 points imor80

For the past few months, as part of my job at Supabase, I have been working on pg\_replicate. pg\_replicate lets you very easily build applications which can copy data (full table copies and cdc) from Postgres to any other data system. Around six months back I was figuring out what can be built by tailing Postgres' WAL. pg\_replicate grew organically out of that effort. Many similar tools, like Debezium, exist already which do a great job, but pg\_replicate is much simpler and focussed only on Postgres. Rust was used in the project because I am most comfortable with it. pg\_replicate abstracts over the Postgres logical replication protocol and lets you work with higher level concepts. There are three main concepts to understand pg\_replicate: source, sink and pipeline.

  1. A source is a Postgres db from which data is to be copied.
  2. A sink is a data system into which data will be copied.
  3. A pipeline connects a source to a sink.

Currently pg\_replicate supports BigQuery, DuckDb local file and, MotherDuck as sinks. More sinks will be added in future. To support a new data system, you just need to implement the BatchSink trait (older Sink trait will be deprecated soon).

pg\_replicate is still under heavy development and is a little thin on documentation. Performance is another area which hasn't received much attention. We are releasing this to get feedback from the community and are still evaluating how (or if) we can integrate it with the Supabase platform. Comments and feedback are welcome.