Skip to content

pg_mooncake

Columnstore Table in Postgres

pg_mooncake · Columnstore Table in Postgres

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2440pg_mooncakepg_mooncake0.3.4OLAPMITRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--NoYesYesYesnono
Requires pg_duckdb 1.2.1+ and scanner 0.0.5 for the installed DuckDB engine.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.3.419 18 17 16 15pg_mooncakepg_duckdb
RPMPIGSTY0.3.419 18 17 16 15pg_mooncake_$vpg_duckdb_$v
DEBPIGSTY0.3.419 18 17 16 15postgresql-$v-pg-mooncakepostgresql-$v-pg-duckdb
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el8.aarch64N/APIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0PIGSTY 0.3.0
el9.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
el9.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
el10.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
el10.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
d12.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
d12.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
d13.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
d13.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u22.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u22.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u24.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u24.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u26.x86_64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
u26.aarch64PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4PIGSTY 0.3.4
PackageVersionOSORGSIZEFile URL
pg_mooncake_190.3.4el9.x86_64pigsty19.1 MiBpg_mooncake_19-0.3.4-1PGSTY.el9.x86_64.rpm
pg_mooncake_190.3.4el9.aarch64pigsty18.1 MiBpg_mooncake_19-0.3.4-1PGSTY.el9.aarch64.rpm
pg_mooncake_190.3.4el10.x86_64pigsty19.1 MiBpg_mooncake_19-0.3.4-1PGSTY.el10.x86_64.rpm
pg_mooncake_190.3.4el10.aarch64pigsty18.1 MiBpg_mooncake_19-0.3.4-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-mooncake0.3.4d12.x86_64pigsty13.0 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-mooncake0.3.4d12.aarch64pigsty11.3 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-mooncake0.3.4d13.x86_64pigsty13.0 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~trixie_amd64.deb
postgresql-19-pg-mooncake0.3.4d13.aarch64pigsty11.3 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~trixie_arm64.deb
postgresql-19-pg-mooncake0.3.4u22.x86_64pigsty13.9 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~jammy_amd64.deb
postgresql-19-pg-mooncake0.3.4u22.aarch64pigsty13.3 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~jammy_arm64.deb
postgresql-19-pg-mooncake0.3.4u24.x86_64pigsty13.9 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~noble_amd64.deb
postgresql-19-pg-mooncake0.3.4u24.aarch64pigsty13.3 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~noble_arm64.deb
postgresql-19-pg-mooncake0.3.4u26.x86_64pigsty13.9 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~resolute_amd64.deb
postgresql-19-pg-mooncake0.3.4u26.aarch64pigsty13.2 MiBpostgresql-19-pg-mooncake_0.3.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_mooncake_180.3.0el8.x86_64pigsty16.5 MiBpg_mooncake_18-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_180.3.0el8.aarch64pigsty14.7 MiBpg_mooncake_18-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_180.3.4el9.x86_64pigsty19.1 MiBpg_mooncake_18-0.3.4-1PGSTY.el9.x86_64.rpm
pg_mooncake_180.3.4el9.aarch64pigsty18.1 MiBpg_mooncake_18-0.3.4-1PGSTY.el9.aarch64.rpm
pg_mooncake_180.3.4el10.x86_64pigsty19.1 MiBpg_mooncake_18-0.3.4-1PGSTY.el10.x86_64.rpm
pg_mooncake_180.3.4el10.aarch64pigsty18.1 MiBpg_mooncake_18-0.3.4-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-mooncake0.3.4d12.x86_64pigsty13.0 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-mooncake0.3.4d12.aarch64pigsty11.3 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-mooncake0.3.4d13.x86_64pigsty13.0 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~trixie_amd64.deb
postgresql-18-pg-mooncake0.3.4d13.aarch64pigsty11.3 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~trixie_arm64.deb
postgresql-18-pg-mooncake0.3.4u22.x86_64pigsty13.9 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~jammy_amd64.deb
postgresql-18-pg-mooncake0.3.4u22.aarch64pigsty13.3 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~jammy_arm64.deb
postgresql-18-pg-mooncake0.3.4u24.x86_64pigsty13.9 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~noble_amd64.deb
postgresql-18-pg-mooncake0.3.4u24.aarch64pigsty13.3 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~noble_arm64.deb
postgresql-18-pg-mooncake0.3.4u26.x86_64pigsty13.9 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~resolute_amd64.deb
postgresql-18-pg-mooncake0.3.4u26.aarch64pigsty13.2 MiBpostgresql-18-pg-mooncake_0.3.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_mooncake_170.3.0el8.x86_64pigsty19.0 MiBpg_mooncake_17-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_170.3.0el8.aarch64pigsty14.7 MiBpg_mooncake_17-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_170.3.4el9.x86_64pigsty19.1 MiBpg_mooncake_17-0.3.4-1PGSTY.el9.x86_64.rpm
pg_mooncake_170.3.4el9.aarch64pigsty18.1 MiBpg_mooncake_17-0.3.4-1PGSTY.el9.aarch64.rpm
pg_mooncake_170.3.4el10.x86_64pigsty19.1 MiBpg_mooncake_17-0.3.4-1PGSTY.el10.x86_64.rpm
pg_mooncake_170.3.4el10.aarch64pigsty18.1 MiBpg_mooncake_17-0.3.4-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-mooncake0.3.4d12.x86_64pigsty13.0 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-mooncake0.3.4d12.aarch64pigsty11.3 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-mooncake0.3.4d13.x86_64pigsty13.0 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~trixie_amd64.deb
postgresql-17-pg-mooncake0.3.4d13.aarch64pigsty11.3 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~trixie_arm64.deb
postgresql-17-pg-mooncake0.3.4u22.x86_64pigsty13.9 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~jammy_amd64.deb
postgresql-17-pg-mooncake0.3.4u22.aarch64pigsty13.3 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~jammy_arm64.deb
postgresql-17-pg-mooncake0.3.4u24.x86_64pigsty13.9 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~noble_amd64.deb
postgresql-17-pg-mooncake0.3.4u24.aarch64pigsty13.3 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~noble_arm64.deb
postgresql-17-pg-mooncake0.3.4u26.x86_64pigsty13.9 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~resolute_amd64.deb
postgresql-17-pg-mooncake0.3.4u26.aarch64pigsty13.2 MiBpostgresql-17-pg-mooncake_0.3.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_mooncake_160.3.0el8.x86_64pigsty16.5 MiBpg_mooncake_16-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_160.3.0el8.aarch64pigsty14.7 MiBpg_mooncake_16-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_160.3.4el9.x86_64pigsty19.1 MiBpg_mooncake_16-0.3.4-1PGSTY.el9.x86_64.rpm
pg_mooncake_160.3.4el9.aarch64pigsty18.1 MiBpg_mooncake_16-0.3.4-1PGSTY.el9.aarch64.rpm
pg_mooncake_160.3.4el10.x86_64pigsty19.1 MiBpg_mooncake_16-0.3.4-1PGSTY.el10.x86_64.rpm
pg_mooncake_160.3.4el10.aarch64pigsty18.1 MiBpg_mooncake_16-0.3.4-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-mooncake0.3.4d12.x86_64pigsty13.0 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-mooncake0.3.4d12.aarch64pigsty11.3 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-mooncake0.3.4d13.x86_64pigsty13.0 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~trixie_amd64.deb
postgresql-16-pg-mooncake0.3.4d13.aarch64pigsty11.3 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~trixie_arm64.deb
postgresql-16-pg-mooncake0.3.4u22.x86_64pigsty13.9 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~jammy_amd64.deb
postgresql-16-pg-mooncake0.3.4u22.aarch64pigsty13.3 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~jammy_arm64.deb
postgresql-16-pg-mooncake0.3.4u24.x86_64pigsty13.9 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~noble_amd64.deb
postgresql-16-pg-mooncake0.3.4u24.aarch64pigsty13.3 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~noble_arm64.deb
postgresql-16-pg-mooncake0.3.4u26.x86_64pigsty13.9 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~resolute_amd64.deb
postgresql-16-pg-mooncake0.3.4u26.aarch64pigsty13.2 MiBpostgresql-16-pg-mooncake_0.3.4-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_mooncake_150.3.0el8.x86_64pigsty16.5 MiBpg_mooncake_15-0.3.0-1PGSTY.el8.x86_64.rpm
pg_mooncake_150.3.0el8.aarch64pigsty14.7 MiBpg_mooncake_15-0.3.0-1PGSTY.el8.aarch64.rpm
pg_mooncake_150.3.4el9.x86_64pigsty19.1 MiBpg_mooncake_15-0.3.4-1PGSTY.el9.x86_64.rpm
pg_mooncake_150.3.4el9.aarch64pigsty18.1 MiBpg_mooncake_15-0.3.4-1PGSTY.el9.aarch64.rpm
pg_mooncake_150.3.4el10.x86_64pigsty19.1 MiBpg_mooncake_15-0.3.4-1PGSTY.el10.x86_64.rpm
pg_mooncake_150.3.4el10.aarch64pigsty18.1 MiBpg_mooncake_15-0.3.4-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-mooncake0.3.4d12.x86_64pigsty13.0 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-mooncake0.3.4d12.aarch64pigsty11.3 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-mooncake0.3.4d13.x86_64pigsty13.0 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~trixie_amd64.deb
postgresql-15-pg-mooncake0.3.4d13.aarch64pigsty11.3 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~trixie_arm64.deb
postgresql-15-pg-mooncake0.3.4u22.x86_64pigsty13.9 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~jammy_amd64.deb
postgresql-15-pg-mooncake0.3.4u22.aarch64pigsty13.3 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~jammy_arm64.deb
postgresql-15-pg-mooncake0.3.4u24.x86_64pigsty13.9 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~noble_amd64.deb
postgresql-15-pg-mooncake0.3.4u24.aarch64pigsty13.3 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~noble_arm64.deb
postgresql-15-pg-mooncake0.3.4u26.x86_64pigsty13.9 MiBpostgresql-15-pg-mooncake_0.3.4-1PGSTY~resolute_amd64.deb
postgresql-15-pg-mooncake0.3.4u26.aarch64pigsty13.2 MiBpostgresql-15-pg-mooncake_0.3.4-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 by package name

pig install pg_mooncake -v 19;   # install for PG 19
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.4 maintains read-only columnstore mirrors of PostgreSQL tables through logical replication into Arrow and Parquet/Iceberg storage. This PGSTY release supports PostgreSQL 15–19 and accepts pg_duckdb 1.2.1 or later. The reference build uses 1.2.2 with DuckDB 2.0.1 and Mooncake scanner 0.0.5.

Configure and Enable

An administrator must retain existing preload entries, add both libraries in this order and restart PostgreSQL:

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

Use the absolute directory from the target server’s pg_config --sharedir, followed by /extension/pg_mooncake; the example is an EL PostgreSQL 17 path. The local scanner works with community extensions disabled. Install using a superuser in a fresh session:

CREATE EXTENSION pg_mooncake CASCADE;

The dependency version is checked. Configure enough replication slots, WAL senders and workers. Source connections need authentication, table access and replication/publication privileges.

Mirror and Inspect

Run mirror creation as a standalone command in a writable session, after source DDL commits:

CREATE TABLE trades (id bigint PRIMARY KEY, symbol text, price real);
CALL mooncake.create_table('trades_analytics', 'trades');
INSERT INTO trades VALUES (1, 'AMZN', 207), (2, 'AMZN', 210);
SELECT symbol, avg(price) FROM trades_analytics GROUP BY symbol;
SELECT * FROM mooncake.list_tables();
CALL mooncake.create_snapshot('trades_analytics');
CALL mooncake.optimize_table('trades_analytics', 'full');

Write to the source table; the mirror is not writable. Use the src_uri argument for a remote source. Fresh reads and snapshots use the source server’s WAL position. External Iceberg readers see published snapshots, while local queries can also see buffered data.

Durability and Upgrades

Version 0.3.3 fixes snapshots that could acknowledge a source commit before Iceberg persisted it. From 0.3.1 or 0.3.2, install matching libraries and scanner, restart, refresh a cached older scanner from the configured repository, then reconnect before updating:

SELECT duckdb.raw_query(format('FORCE INSTALL mooncake FROM %L', current_setting('mooncake.extension_repository')));
ALTER EXTENSION pg_mooncake UPDATE TO '0.3.4';

Take a fresh snapshot of every mirror before using it for backup or migration. From the WAL-based 0.3.0, first stop source writers, compare every mirror against its source, and verify snapshots under the old binaries. Stop PostgreSQL cleanly and preserve complete storage backups and the old _wal offline before starting the new worker. Follow the tagged per-database procedure; a new snapshot cannot recover old WAL already lost. Rebuild unverifiable mirrors from authoritative sources.

Storage and Lifecycle

For physical backups or streaming standbys, set mooncake.data_directory outside PGDATA before creating mirrors, give each instance private storage and back it up separately. Logical dumps do not preserve Moonlink data or replication state. Protect source connection strings and metadata files.

Before renaming or dropping a database with mirrors, drop its mirrors, commit and run SELECT mooncake._reconcile_drops() while the worker is available. Existing leaf partitions receive full replica identity during setup; later partition changes require separate handling. Monitor slot lag and retained WAL, and verify cleanup before discarding source data.

Dependency Compatibility in 0.3.4

The version guard now accepts pg_duckdb 1.2.1 and later; 1.2.1 and 1.2.2 are tested with DuckDB 2.0.1 and scanner 0.0.5. For a newer dependency, verify its PostgreSQL interfaces and provide scanner 0.0.5 built for its DuckDB engine and platform. Update the dependency’s SQL extension to match its library. Direct SQL upgrades are provided from 0.3.0–0.3.3; the earlier WAL, snapshot and scanner-cache maintenance requirements still apply.

Table reader