---
title: "Deploy Postgres x DuckDB"
description: "Postgres 18 with DuckDB using official duckdb image"
category: "Storage"
url: https://railway.com/deploy/postgres-x-duckdb
---

# Deploy Postgres x DuckDB

Postgres 18 with DuckDB using official duckdb image

**[Deploy Postgres x DuckDB on Railway](https://railway.com/template/postgres-x-duckdb)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/postgres-x-duckdb/manifest.json

- **Creator:** Team Lasse
- **Category:** Storage
- **Total deploys:** 2

## Template content

### Postgres x DuckDB https://devicons.railway.com/i/postgresql.svg

- **Image:** ghcr.io/lassejlv/pgduckdb:18

## Documentation

# Deploy and Host Postgres x DuckDB on Railway

Postgres x DuckDB is a PostgreSQL 18 database with the `pg_duckdb` extension preloaded, embedding DuckDB's vectorized analytics engine directly inside Postgres. Run fast analytical queries against your existing tables, or read Parquet, CSV, and Iceberg data straight from object storage — all over the Postgres wire protocol your tools already speak.

## About Hosting Postgres x DuckDB

Hosting Postgres x DuckDB means running a stateful database, so persistence is the primary concern. This template mounts a volume at `/var/lib/postgresql`, the directory PostgreSQL 18 uses for its version-specific cluster, so data survives restarts and redeploys. The image is pinned by immutable digest to PostgreSQL 18 with `pg_duckdb` v1.1.1, making every deployment reproducible. The extension is loaded through `shared_preload_libraries` and created in the default database on first boot, so there is no manual setup step. Analytical queries are memory-hungry by nature, so size the service to your working set and enable a TCP proxy to connect from outside Railway.

## Common Use Cases

- Running analytical and reporting queries on operational Postgres data without exporting it to a separate warehouse
- Querying Parquet, CSV, JSON, and Iceberg files in S3, GCS, or R2 directly with SQL, and joining them against live Postgres tables
- Powering dashboards and embedded analytics that need columnar scan performance but only speak Postgres

## Dependencies for Postgres x DuckDB Hosting

- A persistent volume mounted at `/var/lib/postgresql`
- No external services required — DuckDB runs in-process inside Postgres

### Implementation Details

Connect with any standard Postgres client using `DATABASE_URL`, or `DATABASE_PUBLIC_URL` from outside Railway. Confirm the extension is active:

```sql
SELECT * FROM pg_extension WHERE extname = 'pg_duckdb';
```

Query remote files directly:

```sql
SELECT country, count(*)
FROM read_parquet('s3://my-bucket/events/*.parquet')
GROUP BY country
ORDER BY count DESC;
```

Force a query through the DuckDB engine with `SET duckdb.force_execution = true;`, and configure object storage credentials with `duckdb.create_simple_secret()`.

## Why Deploy Postgres x DuckDB on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Postgres x DuckDB on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/postgres-x-duckdb
