Skip to main content
When duckdb.force_execution is enabled, pg_duckdb handles query execution but still relies on PostgreSQL to scan row-store tables. For scans without selective filters, this hybrid flow can bottleneck on PostgreSQL’s table scan before DuckDB ever gets to apply its vectorized magic. Converting hot analytical tables into parquet-backed columnstores removes that bottleneck—the data is read natively by DuckDB, which keeps the entire pipeline columnar.

Why columnstore tables help

  • Row-store scans stay in PostgreSQL and are serialized tuple-by-tuple into DuckDB batches.
  • Columnstore tables (backed by parquet files) are read directly by DuckDB, avoiding the conversion step and enabling parallel columnar IO.
  • You can keep the original OLTP table for writes while exporting snapshots to parquet whenever you need faster analytics.

Real example: clickstream engagement

1. Create the row-store fact table

2. Insert 3 million sample rows

3. Benchmark aggregates on the row-store table

Run the single-stage aggregation below first with PostgreSQL’s executor, then flip SET duckdb.force_execution = true;. DuckDB still trims latency (about 3.0s → 2.1s), but the scan stays in PostgreSQL so both paths remain in the same ballpark.

Export to parquet for true columnar IO

4. Copy the dataset to parquet files

Prerequisites:
  • Access to an S3-compatible object store that DuckDB can reach.
Exports to object storage always run with DuckDB automatically, so no GUC changes are needed. Relyt ONE’s built-in cache service further boosts bandwidth/latency for repeated parquet scans—nothing to configure on your end.

5. Create an external table

For more details on DuckDB-backed external tables, see external tables.

6. Rerun the query against the columnstore

Scanning parquet with DuckDB removes the PostgreSQL scan bottleneck entirely, dropping the aggregation from ~2 seconds to ~0.8 seconds. Refresh the parquet snapshot whenever you need fresher analytics, and continue to use the OLTP event_log table for day-to-day writes.