Comparison

DuckDB vs PostgreSQL: Analytics and Transactions

Compare DuckDB and PostgreSQL on local Parquet analytics, concurrent transactions and combined architectures. Benchmark the work and data movement that matter.

Editorial update

Decision in brief

Choose DuckDB for analytical scans where a single process can run the work near local files, Parquet or exported datasets. Choose PostgreSQL for a shared online application with independently connecting clients and transactional updates. Keep PostgreSQL authoritative and add DuckDB for reporting when a load test shows enough benefit to justify extract or connection costs.

Choose by workload: PostgreSQL — Shared transactions. DuckDB — Local scans. Use both — Split reporting.
Keep PostgreSQL authoritative and measure the cost of getting fresh data to the reporting path.

See discussion trends ↓

Start with the write and read paths

PostgreSQL is a client-server transactional database. DuckDB is an analytical database that can run in an application process and push eligible filters and column selection into Parquet reads. For a native DuckDB file opened in read-write mode, one writer process can use multiple threads. DuckDB 2.0 documents Quack as a separate client-server option for multiple processes. Include its deployment and contention behavior if you test it.

What you needStart hereLimitation to test
Read a directory of Parquet and aggregate ad hocDuckDB on the machine running the analysisPeak memory, spill storage and cold versus warm reads
Offer an API with concurrent mutations and relational constraintsPostgreSQL with an application connection poolWrite p95, retries, constraint integrity and recovery
Occasional reports over PostgreSQL dataTry SQL on a read replica or via DuckDB with a read-only sourceSource CPU and I/O, connection limits, operator pushdown and query timeouts
Predictable recurring heavy scansTest a PostgreSQL-to-Parquet export queried by DuckDBData freshness, reconciliation, backfills and recovery of the export

What two HN implementations changed

uwemaurer shared a Java-to-PostgreSQL bulk-load comparison that included DuckDB and Arrow on some paths. The post reported binary COPY winning in that setup. The comparison included data conversion and transfer, making it a useful example of why execution time alone misses the cost of a hybrid system.

In the HitKeep Show HN, examo described using an embedded DuckDB for page-view analytics to operate fewer services. The design targeted reporting for a handful of sites. Test whether your analytics fit that serving pattern before assuming it applies to a shared application database.

Measure the application, the report, and the handoff

Use the same representative schema, record count and filters across variants. Report cold and warm runs separately. Account for data extraction or connection setup in end-to-end timing.

  1. Replay a mixed transactional workload in PostgreSQL with expected client concurrency. Record write p95, rejected or retried transactions, CPU and storage.
  2. Run three real reports in PostgreSQL and DuckDB on the same snapshot, for example a selective rollup, a full scan and a join. Verify totals and measure elapsed time and peak memory.
  3. Test a read-only DuckDB connection or a staged export. Log extraction time, source CPU during reporting, output reconciliation, and the maximum age of data on the dashboard.
  4. Keep PostgreSQL alone if operational simplicity meets the report target. Add DuckDB only if gains fit the freshness and recovery limits and the read path preserves online transaction latency.

Related articles