MCPcopy Index your code
hub / github.com/Mooncake-Labs/pg_mooncake

github.com/Mooncake-Labs/pg_mooncake @v0.1.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.2 ↗ · + Follow
645 symbols 1,039 edges 86 files 44 documented · 7%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

pg_mooncake 🥮

Postgres extension for 1000x faster analytics

License Slack Twitter Docs

Overview

pg_mooncake is a Postgres extension that adds columnar storage and vectorized execution (DuckDB) for fast analytics within Postgres. Postgres + pg_mooncake ranks among the top 10 fastest in ClickBench.

Columnstore tables are stored as Iceberg or Delta Lake tables in local file system or cloud storage.

The extension is maintained by Mooncake Labs and is available on Neon Postgres.

Installation

Option 1: Docker

Get started quickly with our Docker image:

docker pull mooncakelabs/pg_mooncake

# server
docker run --name mooncake-demo -e POSTGRES_HOST_AUTH_METHOD=trust -d mooncakelabs/pg_mooncake

# client
docker run -it --rm --link mooncake-demo:postgres mooncakelabs/pg_mooncake psql -h postgres -U postgres

Option 2: From Source

Build for Postgres versions 14–17:

make release -j$(nproc)
make install

Option 3: On Neon Postgres

  1. Create a Neon project
  2. Enable beta extensions:
SET neon.allow_unstable_extensions='true';

Quick Start

  1. Enable the extension
CREATE EXTENSION pg_mooncake;
  1. Create a columnstore table:
CREATE TABLE user_activity(
  user_id BIGINT,
  activity_type TEXT,
  activity_timestamp TIMESTAMP,
  duration INT
) USING columnstore;
  1. Insert data:
INSERT INTO user_activity VALUES
  (1, 'login', '2024-01-01 08:00:00', 120),
  (2, 'page_view', '2024-01-01 08:05:00', 30),
  (3, 'logout', '2024-01-01 08:30:00', 60),
  (4, 'error', '2024-01-01 08:13:00', 60);

SELECT * from user_activity;

Columnstore tables behave just like regular Postgres heap tables, supporting transactions, updates, deletes, joins, and more.

Cloud Storage

Columnstore tables are stored in the local file system by default. You can configure mooncake.default_bucket to store data in S3 or R2 buckets instead.

Note: On Neon, only cloud storage is supported. Neon users must bring their own S3 or R2 buckets or get a free S3 bucket by signing up at s3.pgmooncake.com. For cloud storage configuration instructions, see Cloud Storage. We are working to improve this experience.

Load Data

pg_mooncake supports loading data from: - Postgres heap tables - Parquet, CSV, JSON files - Iceberg, Delta Lake tables - Hugging Face datasets

Columnstore Tables as Iceberg or Delta Lake Tables

Find your columnstore table location:

SELECT * FROM mooncake.columnstore_tables;

The directory contains a Delta Lake (and soon Iceberg) table that can be queried directly using Pandas, DuckDB, Polars, or Spark.

Roadmap

  • [x] Transactional INSERT, SELECT, UPDATE, DELETE, and COPY
  • [x] JOIN with regular Postgres heap tables
  • [x] Load Parquet, CSV, and JSON files into columnstore tables
  • [x] Read existing Iceberg and Delta Lake tables
  • [x] File statistics and skipping
  • [x] Write Delta Lake tables
  • [ ] Write Iceberg tables
  • [ ] Batched small writes and compaction
  • [ ] Secondary indexes and constraints
  • [ ] Partitioned tables ^

^ File statistics and skipping should cover most use cases of partitioned tables in Postgres, including time series.

v0.2.0 Roadmap

Core symbols most depended-on inside this repo

DefineCustomVariable
called by 22
src/pgduckdb/pgduckdb.cpp
DuckDBQueryOrThrow
called by 20
src/pgduckdb/pgduckdb_utils.cpp
DatumToString
called by 14
src/pgduckdb/pgduckdb_options.cpp
RelationGetDescr
called by 14
src/pgduckdb/pg/relations.cpp
IsExtensionRegistered
called by 10
src/pgduckdb/pgduckdb_metadata_cache.cpp
IsColumnstoreTable
called by 6
src/columnstore_handler.cpp
foreach_node
called by 6
src/pgduckdb/utility/copy.cpp
Scan
called by 6
src/pgduckdb/catalog/pgduckdb_schema.cpp

Shape

Function 304
Method 209
Class 131
Enum 1

Languages

C++99%
Rust1%

Modules by API surface

src/pgduckdb/pgduckdb_types.cpp82 symbols
src/columnstore_handler.cpp48 symbols
src/pgduckdb/pgduckdb_table_am.cpp43 symbols
src/columnstore/columnstore_table.cpp22 symbols
src/pgduckdb/pgduckdb_duckdb.cpp19 symbols
src/pgduckdb/pgduckdb_hooks.cpp18 symbols
src/columnstore/columnstore_metadata.cpp18 symbols
src/pgduckdb/pgduckdb_options.cpp16 symbols
src/pgduckdb/catalog/pgduckdb_catalog.cpp16 symbols
src/pgduckdb/pgduckdb_background_worker.cpp15 symbols
src/pgduckdb/catalog/pgduckdb_schema.cpp15 symbols
src/pgduckdb/pgduckdb_node.cpp14 symbols

For agents

$ claude mcp add pg_mooncake \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page