Architecture
The core of pg_mooncake is Moonlink: a rust library which enables sub-second replication of Postgres tables into Iceberg. Moonlink is embedded as a background worker in Postgres.
When you create a columnstore copy of your Postgres tables, Moonlink:
- Performs initial full table copy
- Maintains sync via Postgres logical replication
- Manages columnstore metadata and exposes tables to embedded DuckDB
Write Path​
All inserts, updates, and deletes on regular Postgres rowstore tables are automatically replicated to the columnstore via Moonlink.
- Direct writes to columnstore tables are not supported in v0.2 (unlike v0.1)
- All data modifications (INSERT/UPDATE/DELETE) must be performed on the rowstore table. Changes are automatically replicated to columnstore.
- Roadmap: Retain complete history in columnstore while periodically truncating rowstore tables
Read Path​
All reads on columnstore tables are executed through the embedded DuckDB in Postgres:
- Read-committed isolation level
- Consistent reads with sub-second freshness
Query columnstore tables like regular Postgres tables:
- Join across columnstore and regular tables
- Use any Postgres-compatible BI tool or ORM