You can run SQL on a big Parquet file that sits in a bucket without downloading it first. DuckDB asks the bucket for the byte ranges it needs and nothing else. How many bytes that is depends a lot on the query, so we counted.
We put a 177 MB Parquet file in an S3 API endpoint, pointed DuckDB 2.0.0 at it with the httpfs extension, and read every request from the proxy's access log. Same file, seven queries, three cold runs each.
The test file
- 6,000,000 rows, 7 columns:
event_id,ts(sorted),user_id,country,status,amount,url(a long hex string). - Written by DuckDB with
COMPRESSION ZSTDandROW_GROUP_SIZE 122880: 49 row groups, 177,006,021 bytes. - Rows are sorted by
ts, so each row group covers its own time slice.
| Column | Compressed bytes | Share of file |
|---|---|---|
| url | 111,107,155 | 62.8% |
| amount | 19,825,719 | 11.2% |
| ts | 18,875,579 | 10.7% |
| user_id | 16,909,535 | 9.6% |
| event_id | 6,131,721 | 3.5% |
| country | 2,733,942 | 1.5% |
| status | 1,378,730 | 0.8% |
The server was an S3 API gateway on 127.0.0.1 (rclone serve s3, SigV4 on) behind an nginx that logged one line per request. The network is loopback, so we do not quote timings. Requests and bytes are exact, and you can turn them into time for your own link.
What each query fetched
| Query | Requests (HEAD + GET) | Bytes fetched | Share of file | Transfer at 100 Mbit/s |
|---|---|---|---|---|
| Row count | 1 + 1 | 263,621 | 0.15% | 0.02 s |
Rows in one day (sorted ts) | 1 + 3 | 1,062,341 | 0.6% | 0.08 s |
Average of amount | 1 + 50 | 20,288,965 | 11.5% | 1.6 s |
| Two columns, GROUP BY country | 1 + 90 | 23,438,789 | 13.2% | 1.9 s |
Filter on url (LIKE) | 1 + 98 | 111,347,141 | 62.9% | 8.9 s |
| Every column, full scan | 1 + 99 | 177,006,021 | 100% | 14.2 s |
| Download the file first | 1 | 177,006,021 | 100% | 14.2 s |
Transfer time is bytes × 8 ÷ 100,000,000 for a 100 Mbit/s link, ignoring latency. Every number in the first three columns repeated exactly in all three cold runs.
Why the numbers look like that
- Row count: 2 requests. The row count is in the Parquet footer. DuckDB does a HEAD for the size, then one GET of the last 263,621 bytes.
- One column: 50 GETs. That is the footer plus one GET per row group, 49 of them, each about 400 KB of
amount. DuckDB never touched the other 155 MB. - One day: 3 GETs. Each row group stores min and max of
ts. Because the file is sorted, only one or two row groups can hold June 1, and DuckDB skipped the other 47 without reading them. Sorting before you write is the cheapest speed-up here (DuckDB's own Parquet tips say the same). - Long text column: 63% of the file. A filter on a column that holds most of the bytes reads most of the bytes. Parquet cannot skip what it cannot rule out with min/max, and a
LIKE '%x%'never can. - Full scan: no saving, no loss. 99 GETs, exactly the file size. With many columns requested it needed far fewer GETs than column chunks (343 chunks, 99 GETs), so it clearly reads neighbouring chunks together.
The surprise: LIMIT 10 is not small
<code>SELECT * ... LIMIT 10</code> looks like the cheapest query there is. On the default thread count it fetched between 94 and 145 MB across runs (up to 82% of the file). Each thread starts on its own row group and reads every column of it before the limit can stop anyone. We repeated it with the thread count fixed:
SET threads | GET requests | Bytes fetched (identical in 3 runs) |
|---|---|---|
| 1 | 9 | 14,796,229 |
| 2 | 17 | 29,291,973 |
| 4 | 33 | 58,279,365 |
| 8 | 65 | 116,254,149 |
About 14.5 MB per thread, so the bytes grow with the threads. For a peek at remote data, select the columns you need, or set <code>threads</code> to 1 for the preview.
Asking twice
- Same connection, same query, file cache on (the default): 1 HEAD, 0 bytes. DuckDB checks the object is unchanged and answers from memory.
SET enable_external_file_cache=false: the same average took 51 requests the second time.- A new connection starts cold again. Keep one connection open for a session of queries (a notebook, an API process) and the repeat costs almost nothing.
Point DuckDB at an S3-compatible endpoint
URL_STYLE 'path': DuckDB defaults to virtual-host style for S3, which needsbucket.endpointDNS. Most S3-compatible endpoints want path style. AddUSE_SSL falseonly for a local test like ours.- Public file? Skip the secret and read the plain HTTPS URL,
read_parquet('https://.../events.parquet'). We ran the same seven queries that way against a public URL: the same request counts and bytes. - Globs like
s3://bucket/events/*.parquetuse ListObjectsV2 first, then one footer read per file.
What to do with this
- Sort on the column you filter by before writing. It turned a 177 MB file into a 1 MB read.
- Write columns you query often as their own small columns; keep fat text columns out of the file you scan daily.
- Aim for 50 to 500 MB per file and many row groups. Fewer, bigger GETs beat thousands of tiny files, because each file costs a footer read.
- Select columns, never
*, and watch the thread count on previews. - Keep the connection across queries so the footer and data stay cached.
Range reads are plain HTTP Range requests, the same mechanism as in range requests from a bucket. If you want to fetch big objects fast outside DuckDB, see parallel byte ranges in Python and Go.
Keep your Parquet files in an S3-compatible bucket with no egress fees and query them in place.
Explore tport.spaceTest record and sources
- Run on 2026-11-14: DuckDB 2.0.0 with httpfs, Python 3.13, rclone 1.76.0
serve s3behind nginx 1.31 on one Mac, loopback. This is not tport.space itself; request counts depend on DuckDB and the file, not on the server. - Each query ran 3 times on a fresh DuckDB connection. Requests and bytes come from the nginx access log (
body_bytes_sentper line). - The Q5 (LIMIT 10) byte count varied between runs on the default thread count (94,516,677 to 145,241,541 over six runs); the rest were identical every run.
- DuckDB docs: S3 API support (ENDPOINT, URL_STYLE, USE_SSL, REGION and defaults), Parquet tips (row group size, min/max skipping, sort by the filtered column).