Skip to content

pg_mooncake

Columnstore Table in Postgres

pg_mooncake : Columnstore Table in Postgres

Overview

ID Extension Package Version Category License Language
2440 pg_mooncake pg_mooncake 0.3.0 OLAP MIT Rust
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-- No Yes Yes Yes no no
PGSTY-maintained 0.3.0 fork for pg_duckdb 1.2.0 / DuckDB 2.0.0; bundles local Mooncake v0.0.2 and BUSL-1.1 Moonlink. Requires unsigned extensions and a matching local extension_repository. All 80 RPM/DEB PG14-18 combinations verified and locally indexed; CDN sync pending. No upstream 0.2.0 SQL upgrade script; U24 ARM64 PG14 PL/pgSQL dynamic EXPLAIN remains a known pg_duckdb error; S3/crash/stress paths unverified.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 0.3.0 19 18 17 16 15 pg_mooncake pg_duckdb
RPM PIGSTY 0.3.0 19 18 17 16 15 pg_mooncake_$v -
DEB PIGSTY 0.3.0 19 18 17 16 15 postgresql-$v-pg-mooncake -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
el8.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
el9.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
el9.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
el10.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
el10.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
d12.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
d12.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
d13.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
d13.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u22.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u22.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u24.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u24.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u26.x86_64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
u26.aarch64 N/A PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0 PIGSTY 0.3.0
Package Version OS ORG SIZE File URL
pg_mooncake_18 0.3.0 el8.x86_64 pigsty 16.5 MiB pg_mooncake_18-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_18 0.3.0 el8.aarch64 pigsty 14.7 MiB pg_mooncake_18-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_18 0.3.0 el9.x86_64 pigsty 16.4 MiB pg_mooncake_18-0.3.0-1PGSTY.el9.x86_64.rpm
pg_mooncake_18 0.3.0 el9.aarch64 pigsty 14.7 MiB pg_mooncake_18-0.3.0-1PGSTY.el9.aarch64.rpm
pg_mooncake_18 0.3.0 el10.x86_64 pigsty 16.4 MiB pg_mooncake_18-0.3.0-1PGSTY.el10.x86_64.rpm
pg_mooncake_18 0.3.0 el10.aarch64 pigsty 14.7 MiB pg_mooncake_18-0.3.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-mooncake 0.3.0 d12.x86_64 pigsty 15.3 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-mooncake 0.3.0 d12.aarch64 pigsty 13.5 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-mooncake 0.3.0 d13.x86_64 pigsty 15.4 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-mooncake 0.3.0 d13.aarch64 pigsty 13.6 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-mooncake 0.3.0 u22.x86_64 pigsty 16.6 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-mooncake 0.3.0 u22.aarch64 pigsty 15.8 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-mooncake 0.3.0 u24.x86_64 pigsty 16.6 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-mooncake 0.3.0 u24.aarch64 pigsty 15.8 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-mooncake 0.3.0 u26.x86_64 pigsty 16.5 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-mooncake 0.3.0 u26.aarch64 pigsty 15.8 MiB postgresql-18-pg-mooncake_0.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_mooncake_17 0.3.0 el8.x86_64 pigsty 19.0 MiB pg_mooncake_17-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_17 0.3.0 el8.aarch64 pigsty 14.7 MiB pg_mooncake_17-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_17 0.3.0 el9.x86_64 pigsty 16.4 MiB pg_mooncake_17-0.3.0-1PGSTY.el9.x86_64.rpm
pg_mooncake_17 0.3.0 el9.aarch64 pigsty 14.7 MiB pg_mooncake_17-0.3.0-1PGSTY.el9.aarch64.rpm
pg_mooncake_17 0.3.0 el10.x86_64 pigsty 16.4 MiB pg_mooncake_17-0.3.0-1PGSTY.el10.x86_64.rpm
pg_mooncake_17 0.3.0 el10.aarch64 pigsty 14.7 MiB pg_mooncake_17-0.3.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-mooncake 0.3.0 d12.x86_64 pigsty 15.3 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-mooncake 0.3.0 d12.aarch64 pigsty 13.5 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-mooncake 0.3.0 d13.x86_64 pigsty 15.4 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-mooncake 0.3.0 d13.aarch64 pigsty 13.6 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-mooncake 0.3.0 u22.x86_64 pigsty 16.6 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-mooncake 0.3.0 u22.aarch64 pigsty 15.9 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-mooncake 0.3.0 u24.x86_64 pigsty 16.6 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-mooncake 0.3.0 u24.aarch64 pigsty 15.9 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-mooncake 0.3.0 u26.x86_64 pigsty 16.5 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-mooncake 0.3.0 u26.aarch64 pigsty 15.8 MiB postgresql-17-pg-mooncake_0.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_mooncake_16 0.3.0 el8.x86_64 pigsty 16.5 MiB pg_mooncake_16-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_16 0.3.0 el8.aarch64 pigsty 14.7 MiB pg_mooncake_16-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_16 0.3.0 el9.x86_64 pigsty 16.4 MiB pg_mooncake_16-0.3.0-1PGSTY.el9.x86_64.rpm
pg_mooncake_16 0.3.0 el9.aarch64 pigsty 14.7 MiB pg_mooncake_16-0.3.0-1PGSTY.el9.aarch64.rpm
pg_mooncake_16 0.3.0 el10.x86_64 pigsty 16.4 MiB pg_mooncake_16-0.3.0-1PGSTY.el10.x86_64.rpm
pg_mooncake_16 0.3.0 el10.aarch64 pigsty 14.7 MiB pg_mooncake_16-0.3.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-mooncake 0.3.0 d12.x86_64 pigsty 15.3 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-mooncake 0.3.0 d12.aarch64 pigsty 13.5 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-mooncake 0.3.0 d13.x86_64 pigsty 15.4 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-mooncake 0.3.0 d13.aarch64 pigsty 13.6 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-mooncake 0.3.0 u22.x86_64 pigsty 16.6 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-mooncake 0.3.0 u22.aarch64 pigsty 15.8 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-mooncake 0.3.0 u24.x86_64 pigsty 16.5 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-mooncake 0.3.0 u24.aarch64 pigsty 15.9 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-mooncake 0.3.0 u26.x86_64 pigsty 16.5 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-mooncake 0.3.0 u26.aarch64 pigsty 15.8 MiB postgresql-16-pg-mooncake_0.3.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_mooncake_15 0.3.0 el8.x86_64 pigsty 16.5 MiB pg_mooncake_15-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_15 0.3.0 el8.aarch64 pigsty 14.7 MiB pg_mooncake_15-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_15 0.3.0 el9.x86_64 pigsty 16.4 MiB pg_mooncake_15-0.3.0-1PGSTY.el9.x86_64.rpm
pg_mooncake_15 0.3.0 el9.aarch64 pigsty 14.7 MiB pg_mooncake_15-0.3.0-1PGSTY.el9.aarch64.rpm
pg_mooncake_15 0.3.0 el10.x86_64 pigsty 16.4 MiB pg_mooncake_15-0.3.0-1PGSTY.el10.x86_64.rpm
pg_mooncake_15 0.3.0 el10.aarch64 pigsty 14.7 MiB pg_mooncake_15-0.3.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-mooncake 0.3.0 d12.x86_64 pigsty 15.3 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-mooncake 0.3.0 d12.aarch64 pigsty 13.5 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-mooncake 0.3.0 d13.x86_64 pigsty 15.4 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-mooncake 0.3.0 d13.aarch64 pigsty 13.6 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-mooncake 0.3.0 u22.x86_64 pigsty 16.6 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-mooncake 0.3.0 u22.aarch64 pigsty 15.8 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-mooncake 0.3.0 u24.x86_64 pigsty 16.5 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-mooncake 0.3.0 u24.aarch64 pigsty 15.8 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-mooncake 0.3.0 u26.x86_64 pigsty 16.5 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-mooncake 0.3.0 u26.aarch64 pigsty 15.8 MiB postgresql-15-pg-mooncake_0.3.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_mooncake;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_mooncake;		# install via package name, for the active PG version

pig install pg_mooncake -v 18;   # install for PG 18
pig install pg_mooncake -v 17;   # install for PG 17
pig install pg_mooncake -v 16;   # install for PG 16
pig install pg_mooncake -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_duckdb, pg_mooncake';

Create this extension with:

CREATE EXTENSION pg_mooncake CASCADE; -- requires pg_duckdb

Usage

Sources:

pg_mooncake 0.3.0 creates read-only columnstore mirrors of PostgreSQL tables for analytical queries. Moonlink replicates committed row changes into Arrow buffers and Parquet/Iceberg storage; DuckDB executes scans and aggregates through pg_duckdb. This PGSTY release targets PostgreSQL 14–18 and requires exactly pg_duckdb 1.2.0 with DuckDB 2.0.0 and the matching bundled DuckDB Mooncake extension.

Configure and Enable

Have an administrator configure logical replication and add both libraries to the existing preload list, in this order. Point the repository setting at the installed local DuckDB extension. This example uses the EL PostgreSQL 17 layout:

shared_preload_libraries = 'pg_duckdb,pg_mooncake'
wal_level = logical
duckdb.allow_community_extensions = true
duckdb.allow_unsigned_extensions = true
mooncake.extension_repository = '/usr/pgsql-17/share/extension/pg_mooncake'

For another installation, use the directory under the matching pg_config --sharedir, followed by /extension/pg_mooncake. The tag falls back to the community repository when this setting is absent; it does not automatically select the bundled directory. Unsigned loading is required for this local binary. Ensure sufficient replication slots, WAL senders, and worker processes, then restart PostgreSQL.

CREATE EXTENSION pg_mooncake CASCADE;

Extension creation requires superuser privileges and checks the installed dependency version. Mirror creation opens separate database connections: source DDL must already be committed, and the connecting role must be able to authenticate, read the source, and perform the required replication/publication setup. Run the example in autocommit mode.

Write to the Source, Query the Mirror

CREATE TABLE trades (
    id bigint PRIMARY KEY,
    symbol text,
    traded_at timestamp,
    price real
);
CALL mooncake.create_table('trades_analytics', 'trades');

INSERT INTO trades VALUES
    (1, 'AMZN', '2026-11-05 10:00:00', 207),
    (2, 'AMZN', '2026-11-05 10:05:00', 210),
    (3, 'AAPL', '2026-11-05 10:10:00', 203);
UPDATE trades SET price = 209 WHERE id = 1;
DELETE FROM trades WHERE id = 3;

SELECT symbol, avg(price) FROM trades_analytics GROUP BY symbol;
EXPLAIN SELECT avg(price) FROM trades_analytics WHERE symbol = 'AMZN';

The helper copies existing rows and starts logical replication. Send INSERT, UPDATE, and DELETE to the source table; the mirror uses USING mooncake and is not a writable replacement. Rolled-back source changes are not replicated. Queries can combine mirror data with regular heap tables through supported DuckDB query plans; inspect EXPLAIN for a DuckDB scan.

In this tag, scan and snapshot synchronization use the current backend’s last-commit LSN. Do not treat this as a general guarantee that every other session’s latest write has been ingested, or that a remote source shares the local WAL position. Monitor replication progress for cross-session or remote freshness requirements.

Procedures and Maintenance

Interface Purpose
mooncake.create_table(dst, src, src_uri, table_config) Create a mirror; the last two arguments default to NULL. Use the exact named argument src_uri for a remote PostgreSQL source.
mooncake.list_tables() Return registered tables, commit/flush LSNs, and Iceberg warehouse locations.
mooncake.create_snapshot(dst) Flush buffered data into an Iceberg snapshot at the requested synchronization point.
mooncake.optimize_table(dst, mode) Request compaction; full mode compacts data and indexes.
mooncake.load_files(dst, files) Unsupported in 0.3.0; raises SQLSTATE 0A000.
SELECT * FROM mooncake.list_tables();
CALL mooncake.create_snapshot('trades_analytics');
CALL mooncake.optimize_table('trades_analytics', 'full');

In-database reads can include buffered Arrow data, while external Iceberg readers see published snapshots. Monitor logical-slot lag and retained WAL as well as mirror storage. Dropping the destination table invokes Moonlink cleanup; verify that its registration and replication slot are removed. Preserve the source data until cleanup and any migration have been checked.

Compatibility and Upgrade Boundaries

Mirror setup handles replica identity for source tables without a primary key, including existing leaf partitions. Partitions added later also need REPLICA IDENTITY FULL before receiving writes. TRUNCATE replication and automatic handling of later partition DDL are outside the supported/tested scope. Do not assume arbitrary schema changes or PostgreSQL-specific functions are supported by the mirror.

The v0.3.0 tag provides no in-place SQL upgrade path from 0.2.0. Use a separately validated fresh installation and rebuild mirrors from retained source tables. Replace the PostgreSQL library and matching DuckDB extension together: binaries built for DuckDB 1.4 cannot be reused with DuckDB 2.0. The tagged validation covers local storage and normal restart; S3, crash recovery, and stress behavior are not established by those results.

Table reader