Skip to content

michelp/pg_crdt

 
 

Repository files navigation

pg_crdt tests

pg_crdt (experimental)

pg_crdt is an experimental extension adding support for conflict-free replicated data types (CRDTs) in Postgres.

Documentation:

What is a CRDT?

CRDTs are decentralized data structures that can safely be replicated and synchronized across multiple computers/nodes. They are the enabling technology for collaborative applications like Notion and Figma.

Architecture

The original implementation of this library was relatively naive - we used the Automerge's Rust libary to implement a CRDT as a data type. This had a major limitation: frequently updated CRDTs produce a lot of WAL and dead tuples.

The new implementation improves on this by taking advantage of an advanced in-memory feature in Postgres called an "expanded datum", which can be used for complex in-memory objects. This is described in some detail here:

https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-INMEMORY

There's still work to be done: a more fully fleshed out example application, better change aggregate functions to apply large sets of changes, and explore the ideas of having Postgres use the sync API to sync with other peers.

About

POC CRDT support in Postgres

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 86.4%
  • PLpgSQL 6.8%
  • Dockerfile 3.5%
  • Python 2.4%
  • Other 0.9%