CS PAPERS DEEP-READ · PAPER 23

Dremel: Interactive Queries over Trillions of Rows

Melnik et al. · Google · VLDB 2010

中文 →

What did this paper do?

In 2010, Google described an internal system called Dremel. It let an engineer casually type a query against a table of trillions of rows — "which web pages got the most clicks in the last hour?" — and get the answer back in seconds. At the time that felt like magic: the same job on the earlier batch tool (MapReduce) took minutes or hours. Today's public BigQuery on Google Cloud is built on it.

First, the pain

Once data gets big, "asking a question" gets slow. Traditional databases store data row by row: all of one record's fields (URL, title, click count, time…) sit together. But the thing you want to compute is usually just one column (say "sum of clicks over all pages"). Storing row by row forces the machine to read every whole record off disk just to pick out that one number — most of what it reads is wasted, like flipping through every full page of a book just to check the page numbers.

Idea one: store by column, not by row

Dremel flips it: keep all values of one column together. Every page's "click count" in one long strip, every "title" in another. Now summing clicks means reading only that one strip and touching nothing else — you read exactly what you need. And since values in one column look alike (all numbers, all URLs), they compress beautifully when packed together, so reading is even faster.

The hard part: Google's data isn't a tidy table but is deeply nested — a page record holds "several authors," and each author holds "several languages," like a Russian doll, or a checklist with sub- and sub-sub-items. How do you shred such "nesting-doll data" into flat columns and still reassemble it exactly afterward? Dremel's trick: attach two little tags to each value in a column — one saying "which nesting level it belongs to," one saying "is it the start of a new group, or a continuation of the last." With those two tags, the scattered columns can be losslessly rebuilt into the original nested shape. This encoding is its most technical — and most widely copied — contribution.

Idea two: spread the query across thousands of machines

Columns alone aren't fast enough. Dremel borrows the shape of a search engine: a query arrives at a "root server," which splits the work and hands it down to a batch of "intermediate servers," which hand it further down to thousands of "leaf servers" — each chewing on a small slice of the whole dataset and computing its own local answer ("the click-sum for my slice"). Those partial answers then flow back up the tree, merging layer by layer, until the root assembles the final result. With thousands of machines working at once, trillions of rows get scanned in seconds.

What it gave us

It turned "querying big data" from "submit a job and go get a coffee" into "type a line, glance, tweak, repeat" — interactive exploration. For the first time, analysts could interrogate petabyte-scale data the way they'd use a small database. It became BigQuery, and its "columnar encoding for nested data" became the whole big-data world's standard (today's open-source Parquet and ORC walk the same path).

One honest note: Dremel is fast because it's good at one thing — large-scale, read-only "scan-and-aggregate" analysis. It doesn't update data, doesn't do transactions, and early on barely supported complex joins between big tables. It's not a replacement for an ordinary database.

Remember one thing

Shred nested data into columns (with two little tags that guarantee lossless reassembly), then borrow a search engine's multi-level tree to spread the query across thousands of machines and merge results back up — so even trillions of rows answer in seconds, turning big-data querying into interactive exploration. This is the foundation of BigQuery.

Want to see how the two "level" tags work, what the serving tree looks like, and how fast it runs? → switch to the deep read