Skip to main content
Relyt ONE ships with pg_duckdb, a DuckDB-based columnar execution engine. It accelerates analytical SQL workloads on your operational data with no schema changes or ETL. This hands-on guide walks you through enabling pg_duckdb, running starter queries, and stress-testing a larger dataset so you can feel the speedup directly in psql or your favorite client.

Step 1. Create a sample table and seed data

The following SQL creates a transactional orders table and inserts a few rows for testing.

Step 2. Route queries through DuckDB

Enable the DuckDB execution engine for the current session. With this single GUC, all supported queries automatically run on the vectorized engine.
To make DuckDB the default executor for every new connection, set the GUC at the role or database level (changes apply only to sessions started after the ALTER runs):
No query rewrites are required—keep using PostgreSQL syntax.

Step 3. Run analytical queries

Aggregate revenue by product

Aggregate revenue by day

These queries now execute on DuckDB’s columnar engine, delivering lower latency and more predictable performance for aggregation-heavy workloads.

Real analytical workload example

For a more realistic benchmark, seed a sales_log fact table with three million synthetic transactions and then route a complex window query through DuckDB.

Create the transactional table

Insert 3 million sample rows

Refresh planner statistics so both executors have accurate metadata:
Optionally confirm the on-disk size:

Benchmark the window-heavy query

  1. Run with PostgreSQL’s executor (default)
    Leave duckdb.force_execution unset (or explicitly SET duckdb.force_execution = false;) and execute the analytical query below. Record the elapsed time from EXPLAIN ANALYZE.
  2. Enable DuckDB and rerun
    Turn on DuckDB for the current session and immediately run the same SQL again to compare results:
The query operates directly on the sales_log row-store table, grouping three million rows into 10,000 user partitions, applying a moving average window, filtering anomalies, and sorting the top 100 largest deviations:
Your mileage may vary based on hardware and background workload, but the pattern—run once with PostgreSQL, flip the GUC, rerun with DuckDB—makes it easy to validate the speedup yourself.

Key benefits

  • Seamless integration: Works with existing PostgreSQL SQL and tooling.
  • High performance: Vectorized execution with automatic parallelism for scans and aggregations.
  • Zero friction: A single session parameter (duckdb.force_execution) controls the engine.

Operational tips

Automatic fallback

If a statement includes features not supported by DuckDB, Relyt automatically falls back to the default PostgreSQL executor. No manual intervention is required.

Inspect the execution engine

Use EXPLAIN to verify whether DuckDB handled the query:
Look for DuckDB nodes in the plan to confirm the handoff. If you only see PostgreSQL plan nodes, the fallback path was used.