DuckDB vs SQLite: same question, two shapes of file (and when to use which)
DuckDB and SQLite are both one-file databases that live inside your program, but SQLite stores rows in B-tree pages and DuckDB stores compressed columns in row groups of 122,880 rows. In ClickBench's published results a sum over 100 million rows takes SQLite 405 seconds and DuckDB 0.061; in a 2022 paper co-written by SQLite's own developers, SQLite ran small transactions 10 to 500 times faster. Storage, concurrency, file size, Python, DuckDB's SQLite extension, and a decision card.
Four hundred and five seconds, or six hundredths of a second. That’s the same question, a sum and an average over 99,997,497 rows, answered by SQLite and by DuckDB in ClickBench’s published results. Both are a single file. Both run inside your program, with no server. So where does a gap of about 6,600 times come from?
From the shape of the file. This post draws the same table both ways, then runs two rounds with published numbers only: analytics, where DuckDB wins by miles, and point lookups and small writes, where SQLite wins by up to 500 times. Round three is the one most comparisons skip: you can use both on the same file. No benchmarks were run for this post; every number comes from a linked source, and I say who measured it.
Same promise outside, different file inside
SQLite’s own docs put its job in one line: “SQLite does not compete with client/server databases. SQLite competes with fopen()” (Appropriate Uses). DuckDB took that idea for analytics: “there is no DBMS server software to install”, it is “completely embedded within a host process”, and it is “designed to support analytical query workloads” (Why DuckDB). The 2022 VLDB paper we’ll come back to calls it “the SQLite for analytics”.
Current versions: SQLite 3.54.1 (16 Oct 2026) and DuckDB 2.0.1 (20 Nov 2026).
SQLite stores rows. “The complete state of an SQLite database is usually contained in a single file” made of fixed-size pages, 4,096 bytes by default since version 3.12.0 (file format, page size change). Each table is a B-tree keyed by the rowid, with all data in the leaf pages, and each row is one record: a header with a type code per value, then the values side by side.
DuckDB stores columns. A table is split into row groups, “horizontal partitions of the data” (storage docs), of 122,880 rows each by default (DEFAULT_ROW_GROUP_SIZE in storage_info.hpp, which is 60 vectors of 2,048 values). Inside a row group every column is its own segment, compressed with whichever method fits it best (constant, RLE, bit-packing, frame of reference, dictionary, FSST for strings, Chimp/Patas for floats, per Lightweight Compression in DuckDB), and DuckDB “automatically creates zonemaps (also known as min-max indexes)” for every column (indexing docs).
Round 1: analytics
To answer SELECT SUM(price) FROM orders, SQLite walks every leaf page, and every page is full of whole rows: ids, customers and cities come along with the prices. DuckDB opens one column segment per row group. Add a filter (WHERE price > 900) and the min-max zonemaps let it “skip any row group whose min-max range does not contain that filter value”.
ClickBench, run by ClickHouse, has published results for both on the same machine, an AWS c6a.4xlarge (16 vCPU, 32 GiB), with one flat table of 99,997,497 rows and 105 columns. The numbers below are the best of the second and third run (“hot”) from the result files (SQLite, 2025-07-11, DuckDB, 2026-11-12):
| SQLite | DuckDB | |
|---|---|---|
Q3: SUM(AdvEngineID), COUNT(*), AVG(ResolutionWidth) |
405.31 s | 0.061 s |
Q2: COUNT(*) WHERE AdvEngineID <> 0 |
401.72 s | 0.043 s |
| Sum of the 42 queries both finished | 12,858.8 s (3 h 34 min) | 18.5 s |
Q37–Q43: one CounterID, one month |
0.32–1.70 s | 0.033–0.087 s |
Database file (data_size) |
75.8 GB | 20.5 GB |
Read it with the fine print. ClickBench is an analytics benchmark, built for engines like DuckDB. DuckDB uses all 16 cores; SQLite runs a query on one thread (the paper notes “SQLite generally does not use multiple threads”). The SQLite run is Ubuntu’s packaged sqlite3 from July 2025 and the DuckDB run is 2.0 from November 2026, 16 months apart. Both entries are marked “tuned: no”, and SQLite has no result for one query (Q29).
Two patterns stand out. Almost every full-table question costs SQLite about 400 seconds, whether it touches one column or several: that’s the row layout, it reads the pages either way. And the last seven queries show what SQLite’s B-tree is for. ClickBench’s SQLite table has PRIMARY KEY (CounterID, EventDate, UserID, EventTime, WatchID), and queries 37 to 43 ask for one counter’s traffic in July 2013. SQLite walks from the root to just those pages and drops from about 400 seconds to about one. DuckDB is still faster there, so in ClickBench SQLite never wins a query.
How much bigger is the SQLite file?
Almost four times: 75.8 GB against 20.5 GB for the same table (SQLite imported it from CSV, DuckDB from Parquet). Columns compress well because each holds one type with similar values side by side. DuckDB’s own docs give a rule of thumb: “loading 100 GB of uncompressed CSV files into a DuckDB database file will require 25 GB of disk space.” The VLDB paper found the same direction on its own datasets: SQLite needed 90% more space for TATP (520 MB vs 270 MB) and 60% more for SSB (2.8 GB vs 1.8 GB), partly because DuckDB stores a boolean as a single bit and SQLite as a 1-byte integer.
The paper by SQLite’s own developers
“SQLite: Past, Present, and Future” (PVLDB 15(12), 2022) is by Kevin P. Gaffney, Martin Prammer and Jignesh M. Patel of UW-Madison, and Larry Brasfield, D. Richard Hipp and Dan Kennedy of SQLite (Hipp is SQLite’s lead developer). They compared SQLite 3.38.0 with DuckDB 0.3.2, both built with -O3, DuckDB “restricted to a single thread”, on a 10-core Xeon cloud server and a Raspberry Pi 4.
On the Star Schema Benchmark, “DuckDB is substantially faster than SQLite”: 3–8× on query flight 1, 30–50× on flight 2. Profiling SQLite’s bytecode engine showed the time going into B-tree probes during joins (the SeekRowid instruction) and value extraction, not query interpretation, so they added Bloom filters to SQLite’s join loop. Result: “On the Raspberry Pi, SQLite is now 4.2X faster on SSB”, and 2.7× overall (up to 7× per query) on the server. It shipped: the SQLite 3.38.0 release notes (22 Feb 2022) say “Use a Bloom filter to speed up large analytic queries.” The paper’s conclusion is still honest: “DuckDB is still considerably faster than SQLite on SSB.”
Round 2: point lookups and small writes
Now fetch order 42, change its price and commit. SQLite follows the B-tree from the root to one leaf page, where the whole row sits together. DuckDB has to find row 42 in one segment per column and stitch the row back together, and its engine, in the paper’s words, “is optimized for bulk updates, such as adding a column to a table or appending a large batch of rows, rather than the fine-grained operations typically present in OLTP workloads.”
The same paper measured that with TATP, a telecom transaction benchmark where 80% of transactions are read-only. On the cloud server, “SQLite-WAL reaches a throughput of 10 thousand TPS, which is 10X faster than DuckDB for the small database and 500X faster for the large database”; on the Raspberry Pi, 2× and 60×. That was DuckDB 0.3.2 from early 2022, and I found no newer published comparison of this kind. DuckDB’s current docs still give the same advice: “avoid using lots of individual row-by-row INSERT statements when inserting more than a few rows” (Insert statements), or wrap them in one transaction.
Who can write at the same time
- SQLite in WAL mode: “readers do not block writers and a writer does not block readers”, but “there can only be one writer at a time”, and “all processes using a database must be on the same host computer” (WAL). Its own guidance: “any site that gets fewer than 100K hits/day should work fine with SQLite.”
- DuckDB: “one process can both read and write to the database”, or many processes can open it read-only (Concurrency). Inside that process, threads write in parallel under MVCC and “appends will never conflict, even on the same table”; two threads updating the same row get a conflict error. For writers in several processes, DuckDB 2.0 points to Quack, its client-server protocol, at which point it’s no longer just a file.
Round 3: use both
DuckDB’s SQLite extension “allows DuckDB to directly read and write data from a SQLite database file”, and it is “transparently autoloaded on first use”:
ATTACH 'app.db' AS app (TYPE sqlite);
SELECT city, SUM(price) FROM app.orders GROUP BY city;
Your app keeps doing small transactions on SQLite, and the heavy reports run in DuckDB on the same file (locking is handled by the SQLite library). Two things to know: SQLite is “weakly typed” and DuckDB is strongly typed, so a column with mixed values can raise a type error (SET GLOBAL sqlite_all_varchar = true; reads everything as text), and you can COPY the results straight to Parquet.
In Python, sqlite3 is already in the standard library (“a lightweight disk-based database that doesn’t require a separate server process”, docs). DuckDB is pip install duckdb, and results come back as pandas, Polars or Arrow (Python API):
import sqlite3 # standard library
import duckdb # pip install duckdb
duckdb.sql("ATTACH 'app.db' AS app (TYPE sqlite)")
duckdb.sql("SELECT * FROM app.orders").pl() # .df() for pandas, .fetchall() for tuples
Don’t count SQLite out
The SQLite team thinks “there are over one trillion (1e12) SQLite databases in active use” (Most Widely Deployed). In the 2022 paper its library was 900 KB to 1.5 MB against DuckDB’s 32 to 37 MB, and “the developers intend to provide support for SQLite through the year 2050”. For small blobs, the SQLite team even measured it 35% faster than the filesystem.
DuckDB or SQLite?
| If your workload is… | Pick |
|---|---|
| App state, a phone or desktop app, small transactions, lots of point lookups | SQLite |
| Sums, group-bys, scans over many rows, Parquet and CSV files, a notebook full of analysis | DuckDB |
| An app on SQLite that also needs reports | Both: ATTACH the SQLite file from DuckDB |
| Many writers from many processes or machines | Neither as a plain file: a client-server database (or DuckDB’s Quack) |
Same question, two shapes of file. One reads whole rows, the other reads one column, and the right one depends on the question you ask most. Next up: DuckDB vs Postgres, when your analytics outgrow one file.