pg_duckdb
pg_duckdb : DuckDB Embedded in Postgres
Overview
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | duckdb |
| Need By | pg_mooncake |
| See Also | pg_mooncake pg_ducklake duckdb_fdw pg_parquet pg_lake pg_clickhouse aws_s3 file_fdw pg_bulkload columnar |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el8.aarch64 | N/A | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| el9.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 |
| el9.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 |
| el10.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 |
| el10.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 | PIGSTY 1.2.1 |
| d12.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d12.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d13.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| d13.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u22.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u22.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u24.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u24.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u26.x86_64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
| u26.aarch64 | PIGSTY 1.2.1 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 | PIGSTY 1.2.0 |
Source
github.com/duckdb/pg_duckdb
pg_duckdb-1.2.1.tar.gz curl-8.23.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources:
pg_duckdb embeds DuckDB’s analytical engine in PostgreSQL and can query ordinary PostgreSQL tables and external files. Release 1.2.1 embeds DuckDB 2.0.1; upstream lists PostgreSQL 14–18. It is not relocatable and needs cluster preload.
Enable and Compare a Query
Add the library to the existing setting, then restart PostgreSQL:
As a superuser, install it and inspect an analytical query:
Ordinary queries use PostgreSQL unless forced; DuckDB-only functions or remote storage operations choose DuckDB automatically. Inspect the plan and benchmark representative data. read_parquet, read_csv and read_json read external data, while duckdb.create_simple_secret configures storage credentials. Keep secrets out of shared SQL history and verify the access boundary before granting execution.
Privileges and Configuration
duckdb.postgres_role selects the role allowed to execute DuckDB, manage secrets and use MotherDuck data; by default only superusers may do so. A configured role can be created during installation. Grant membership deliberately because it exposes shared DuckDB secrets and data. Local filesystem access is restricted separately through PostgreSQL server-file roles and DuckDB filesystem settings. Community extension loading is an explicit administrator choice.
Transaction and Compatibility Limits
A transaction may not write both PostgreSQL and DuckDB tables, or mix DDL for both engines. Keep duckdb.unsafe_allow_mixed_transactions disabled: bypassing the rule can commit one side only and lose consistency. Execution inside PostgreSQL functions is also disabled by default; the unsafe setting for it has known crash risks.
Version 1.2.1 supports nested fixed-length arrays and improves numeric and floating conversions. It fixes parallel-worker memory reads, cancellation cleanup and secret-bearing log/statistics handling. These fixes do not remove the need to restrict credentials and review type/query compatibility. Install matching libraries, follow preload restart requirements, and update the SQL extension in each database before relying on new behavior.