Faster Parquet with a Column Cache

☕ This is the sequel to Why Parquet Structure Matters for Fast Queries. There is a summary table at the end, followed by references.

The first paper was about the file: how to structure Parquet so most of it is never read.

Parquet files tend to live in slow buckets: S3 or GCS.

This paper is about the runtime: how do we avoid reading the same Parquet data again and again from slow buckets?

We discuss two low-cost cache holders: the /tmp of a hot lambda (a serverless instance such as AWS Lambda or Cloud Run), and the browser.

The gain shows on the first screen. A top dashboard page that scans 300MB from the bucket waits about 10 seconds.

On a column cache, the same page opens in about 0.5 seconds.

Top dashboard page: about 10 seconds from the bucket, about 0.5 seconds from a column cache
Top dashboard page: about 10 seconds from the bucket, about 0.5 seconds from a column cache

Part I — Caching Is the Solution

1. Many People, a Similar Query of the Day

Our coffee network has dozens of managers.

Every morning, they all open the same dashboard.

And they all ask about the same day.

Tile Columns it needs (today's row group)
Sales today timestamp, quantity, unit_price
Morning sales timestamp, quantity, unit_price
Best-selling flavor timestamp, flavor, quantity
Best-selling product timestamp, product, quantity

Different managers, different tiles, but the same few column chunks of one row group.

manager 1 ─┐
manager 2 ─┤                          ┌─────────────┐
manager 3 ─┼──→  hot lambda  ─ once ─→│  GCS / S3   │
   ...     │     /tmp cache           └─────────────┘
manager N ─┘

Without a cache, every query of every manager fetches those chunks from the bucket again.

There is a reason the engine forgets: in a lambda-based query system, every query runs in a fresh process that reads the Parquet. When the query ends, the process and everything it read are gone.

But the lambda instance stays alive between requests, and so does its /tmp.

Many managers, one hot lambda, one fetch from the bucket
Many managers, one hot lambda, one fetch from the bucket
Bytes from the bucket, one morning of dashboards (illustrative)

no cache     ██████████████████████████████████████  every query refetches
/tmp cache   ███▏                                     first query only

A Security Caveat

A shared cache is shared by everyone who uses the instance.

On a hot path, the bytes come from /tmp, not from the bucket. So the bucket never checks who is asking.

cold   manager A → bucket checks A → bytes → /tmp
hot    manager B → /tmp → bytes                 (no bucket check)

In most cases this is valid.

A lambda typically serves one tenant: one company, one dataset. Access is checked before the query starts, and every user who passes that check may read the same files anyway.

The caveat matters when users of the same instance have different rights to the same file:

Then the access check must run before every query, not only on a cache miss. Or each permission scope gets its own instance or its own cache directory.

In some cases, we can sign the cache with a user-specific token.

The cache directory is no longer named by the file alone, but by the file and the user's token:

shared   /tmp/cols_cache/hash(file URL)/
signed   /tmp/cols_cache/hash(file URL + user token)/

Manager B computes a different directory, finds nothing, and goes to the bucket, where B's own rights are checked.

Manager A's cached chunks can only be found with A's token.

The price is less sharing: each user warms their own cache. For data that only one user may read, that is exactly what we want.

When many people ask about the same day, the hot lambda is the place to keep its bytes.


2. Same Person — Data Locality

After the morning dashboard, one manager starts to explore.

London only. Then London by hour. Then London, mornings, Vanilla.

Each question is new, but the data is not: it is the same branch, the same days, the same few columns.

London                 ┐
London by hour         ├──→  same row groups, same column chunks
London mornings Vanilla┘

One person tends to stay near the same data. This is data locality.

The closest place to that person is their own browser.

One person exploring the same chunks inside the browser
One person exploring the same chunks inside the browser
                 network     server cost
lambda /tmp        yes          yes
browser cache      no           no

A browser cache serves no one else, but for its one person it is the fastest and the cheapest place.

When one person keeps exploring the same data, the browser can be the cache.


3. Keep the Column Chunks

What should we keep?

A quick reminder from the first paper:

sales.parquet
┌──────────────────────────────────────────────────────┐
│ RG today      │ timestamp │ product │ flavor │ qty │…│
├──────────────────────────────────────────────────────┤
│ RG yesterday  │ timestamp │ product │ flavor │ qty │…│
├──────────────────────────────────────────────────────┤
│ Footer        min/max + offset + length              │
│               of every column chunk                  │
└──────────────────────────────────────────────────────┘

The whole file is too much: one day is about 0.09% of three years of sales.

The query result is too narrow: "Morning sales" and "Evening sales" are different results built from the same bytes.

The right unit is the one Parquet already gives us: the column chunk.

footer → offset + length of a column chunk
                         ↓
         cache key = "<offset>-<length>"

The footer already tells us exactly where each chunk starts and how long it is.

So the cache needs no index of its own: the chunk's byte range is its name.

A column chunk's offset and length become its cache key
A column chunk's offset and length become its cache key
/tmp/cols_cache/<hash of file URL>/
    .size                  file size, so the footer needs no network call
    44941312-65536         footer
    1048576-812340         RG today · timestamp
    3211264-402118         RG today · quantity
    ...

Every query now takes one of two paths.

COLD                                    HOT
read footer      ← network              read footer      ← local
prune row groups                        prune row groups
fetch needed chunks ← network           needed chunks    ← local
  (in parallel, exactly what the
   footer + pushdown asked for)
save each chunk under its key
scan                                    scan

The hot path makes zero network calls.

Where the chunk lives Example latency per read Example throughput
Object storage (GCS / S3) ~30–100 ms ~100–500 MB/s
Local disk (/tmp) ~0.1–1 ms ~1–5 GB/s
Memory microseconds ~20–100+ GB/s

These are illustrative numbers rather than guarantees.

For our dashboard, the effect on query time looks like this:

Query time, same dashboard tile (illustrative)

cold  ██████████████████████████████  ~1 s     footer + chunk round trips to the bucket, then scan
hot   ▏                               ~10 ms   scan only, from /tmp     → up to 100× faster

The gain depends on where the cold query spent its time.

A typical tile scans a few MB of column chunks. From /tmp or memory, that scan takes about 10 ms. From the bucket, the same chunks wait for the footer round trip and then for the chunk GETs: a second or more. Such a tile gets close to 100× faster.

A heavy query that computes for seconds gains less, closer to 2×: the cache removes the network, not the work.

Cache column chunks, not query results: different questions share the same bytes.


Part II — Implementation: a DuckDB Extension

4. The DuckDB Extension

08:00 — the first manager opens the dashboard.

We implemented the cache as a DuckDB extension, cols_cache.

A query reads a remote Parquet file through a table function:

SELECT flavor, SUM(quantity) AS cups
FROM cols_cache('gs://coffee/sales.parquet')
WHERE timestamp >= '2026-08-26'
GROUP BY flavor;

Underneath, DuckDB's own Parquet reader reads through a virtual file system, colscache://.

Every read DuckDB makes is answered from the cache, or fetched and then cached.

DuckDB Parquet reader
        ↓  Read(offset, length)
colscache:// file system
        ↓
/tmp/cols_cache/<hash>/<offset>-<length>   hit  → read local file
        ↓ miss
Node helper → GCS Range-GET → write file  → read local file

On a miss, a small Node.js helper process fetches the byte range from the bucket and writes it into the cache.

The colscache file system: hit from /tmp, miss through the Node helper
The colscache file system: hit from /tmp, miss through the Node helper

The cold path, step by step:

  1. Tail. One suffix GET of the last 64 KiB returns the footer and, in its headers, the file size. The size is saved in .size.
  2. Prune. DuckDB pushes the projection and the filters into the scan. Row groups whose footer min/max cannot match are skipped.
  3. Prefetch. Exactly the pushed-down column chunks of the surviving row groups are fetched, six in parallel.
  4. Save. Each chunk is written to a temporary file and then renamed, so a parallel reader sees a whole chunk or nothing.
  5. Scan. One parallel work unit per (file, row group).

The hot path skips steps 1 and 3: the size comes from .size, the footer and the chunks come from /tmp.

GCS calls per query (from the logs)

cold   tail + one GET per needed column chunk
hot    0

The cache lives as long as the lambda instance lives.

When the instance is recycled, its /tmp is gone, and the next query is cold again.

The extension keeps DuckDB's own Parquet reader, and changes only where its bytes come from.


5. DuckDB WASM in the Browser

14:00 — a manager opens the dashboard in the browser.

The same extension code is compiled to WebAssembly and linked into DuckDB WASM.

Only one thing changes: how a missing byte range is fetched.

DuckDB reads synchronously. The browser fetches asynchronously.

So DuckDB runs in a Web Worker, where synchronous requests are allowed, and the extension calls three small JavaScript hooks:

haveRange    is this range already cached?
faultRange   fetch it now (synchronous Range request)
readRange    copy it into DuckDB's memory

A synchronous fetch blocks the scan, so the worker avoids it.

Before the query, it reads the footer, plans the needed column chunks of the matching row groups, and fetches them in parallel. When the scan starts, the chunks are already there.

before the query                 during the query
tail → footer → plan             haveRange → yes → readRange
parallel fetch of the plan       (rarely: faultRange)
DuckDB WASM in a Web Worker: plan and prefetch before the query
DuckDB WASM in a Web Worker: plan and prefetch before the query

Where do the chunks live?

worker memory   survives the next query, not the closed tab
OPFS            survives the closed tab and the next worker

OPFS is the browser's private file system: one file per Parquet object, plus a map of the cached pages. A fresh worker that finds those pages makes zero network calls.

The browser has no disk shared with anyone else. Its cache serves exactly one person, which is exactly what data locality asks for.

The browser runs the same cache with a different fetch: plan the chunks before the query, so the scan never waits.


Part III — Living with the Cache

6. Cache Invalidation

Next day — new sales arrive.

The cache key is the file URL plus a byte range.

If a file is rewritten under the same URL, the cached chunks no longer describe it.

There are two ways to stay correct.

Keep the cache creation time. Compare it with the Parquet file's update time, and drop the cached file directory when the file is newer.

cache created  08:00
file updated   09:30   → newer → drop cache, refetch

This costs one metadata call per check, so the hot path is no longer exactly zero calls.

Manifests with file names. Never rewrite a file. Write new data to a new file name, and publish a small manifest listing the current files.

manifest.json
    sales-2026-08-26.parquet
    sales-2026-08-27.parquet      ← new name, new cache directory

A new name means a new cache directory, so nothing stale can be read. Old directories simply stop being used.

A manifest of file names: unchanged files keep their cache, new data gets a new name
A manifest of file names: unchanged files keep their cache, new data gets a new name

This fits the incremental DayMonthQuarterYear layout from the first paper: most row groups never change, and their cached chunks stay valid.

The easiest cache to invalidate is one whose files never change: new data, new name.


7. What We Learned

Chapter Chapter name What we learned
1 Many People, a Similar Query of the Day Many people ask about the same day; a hot lambda can serve them all from /tmp.
2 Same Person — Data Locality One person stays near the same data; the browser can be their cache.
3 Keep the Column Chunks The column chunk is the natural cache unit; its byte range is its key.
4 The DuckDB Extension Same Parquet reader, cached bytes: zero bucket calls on the hot path.
5 DuckDB WASM in the Browser Same extension, different fetch: plan and prefetch before the synchronous scan.
6 Cache Invalidation Compare update times, or better, never rewrite: new data, new file name.

The first paper taught us to fetch fewer bytes. This paper is about fetching them only once.


References

  1. Why Parquet Structure Matters for Fast Queries ../parquet/paper.md The first paper: row-group and column skipping.

  2. DuckDB — Parquet Overview https://duckdb.org/docs/stable/data/parquet/overview Projection and filter pushdown into the Parquet scan.

  3. MDN — Origin Private File System https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system The browser's private file system used for a persistent cache.

  4. AWS Lambda — Execution environment lifecycle https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtime-environment.html Why /tmp lives only while the instance is warm.

Comments and discussion on LinkedIn →