Understanding Lance (2): Data File Format

The previous article analyzed the organization and roles of the various files in Lance. This article takes a detailed look at the data file structure (that is, the files with the .lance suffix) and compares it with Parquet. It should be noted that this article will mention Lance’s intra-page encodings (such as MiniBlock, FullZip, etc.); the details of that part will be explained in a later article.

Lance Data File Structure #

As shown below, a data file is usually divided into the following major parts:

  • Data pages that store column data
  • Global Buffers (GB for short), storing file-level data that belongs to no page and no column
  • An array of Column Metadata storing the metadata of each column
  • The Column Metadata Offset Table (CMO for short), storing the position and size of each Column Metadata
  • The Global Buffers Offset Table (GBO for short), storing the position and size of each Global Buffer
  • And finally a fixed-length Footer
┌──────────────────────────────────────────┐
│ Data Pages                               │  ← data pages of each column
│   (GB[1..] may interleave here)          │
│   Data Buffer 0*                         │
│   ...                                    │
│   Data Buffer BN*                        │
├──────────────────────────────────────────┤
│ Global Buffer 0: FileDescriptor          │  ← GB[0] (contains schema), variable length
├──────────────────────────────────────────┤◀── column_meta_start
│ Column Metadatas                         │  ← one independent protobuf per column
│   Column 0 Metadata                      │
│   ...                                    │
│   Column CN Metadata                     │
├──────────────────────────────────────────┤◀── column_meta_offsets_start
│ Column Metadata Offset Table (CMO)       │  ← 16B × CN
├──────────────────────────────────────────┤◀── global_buff_offsets_start
│ Global Buffers Offset Table (GBO)        │  ← 16B × GN
├──────────────────────────────────────────┤◀── file_len - 40
│ Footer (fixed 40 bytes)                  │
│   u64: column_meta_start                 │
│   u64: column_meta_offsets_start         │
│   u64: global_buff_offsets_start         │
│   u32: number of global buffers          │
│   u32: number of columns                 │
│   u16: major version                     │
│   u16: minor version                     │
│   "LANC"                                 │
└──────────────────────────────────────────┘

GB[1..] are written in place via add_global_buffer during encoding, so they may land between data pages; GB[0] is written after all pages are done and before the column metadata, so its position is fixed.

The following sections explain each of these parts.

Data Pages #

Starting from file offset 0 are the data pages; every buffer within a page is 64B-aligned:

file offset 0
┌──────────────────────────────────────────┐
│ page 0 ─ buffer 0   [64B aligned]        │
│          buffer 1   [64B aligned]        │
│          ...                             │
│ page 1 ─ ...                             │
│                                          │
└──────────────────────────────────────────┘

Pages themselves are not required to be aligned; it is the buffers within a page that are aligned (padded where necessary). Data pages store the actual column data, and the intra-page layout varies with the column type and encoding; this part is left for later articles.

Global Buffers #

Global Buffers hold “file-level” auxiliary data that belongs to no page and no column, such as the schema, file-level indices, and column statistics. The reason for carving out a separate area instead of stuffing them into column metadata is that the container must remain neutral to extensions: indices and statistics have no column number, and no column should be fabricated just to hold them.

It has only one hard rule:

  • GB[0] is always the FileDescriptor (schema + row count)
  • GB[1..] are arbitrary bytes, whose semantics are referenced via key → "index[:args]" entries in Schema.metadata

Each entry in the GBO table is 16 bytes, recording the position and length of each Global Buffer:

GBO[i] = (GB[i].position, GB[i].size)

GBO (16B × num_global_buffers)
┌────────────────────┬────────────────────┐
│ position u64       │ size u64           │ → GB[0]
├────────────────────┼────────────────────┤
│ position u64       │ size u64           │ → GB[1]
├────────────────────┼────────────────────┤
│ ...                                     │
└─────────────────────────────────────────┘

GB[0] is always the FileDescriptor:

message FileDescriptor {
  Schema schema = 1;
  uint64 length = 2;    // total number of rows in the file
}

message Schema {
  repeated lance.file.Field fields = 1;
  map<string, bytes> metadata = 5;
}

This is the only source of “type information” in the file format:

  • The file container itself has no concept of types;
  • A column is just a column index, and a buffer is just a global buffer index;
  • Types, nullability, nested structures, and field ids all live in GB[0].

Column Metadata #

Column Metadata stores the metadata of each column, with one independent protobuf per column:

message ColumnMetadata {
  Encoding encoding = 1;        // how to interpret column-level buffers; usually empty under structural encodings
  repeated Page pages = 2;

  message Page {
    repeated uint64 buffer_offsets = 1;
    repeated uint64 buffer_sizes   = 2;
    uint64 length                  = 3;   // number of rows in the page
    Encoding encoding              = 4;   // PageLayout
    uint64 priority                = 5;   // row number of the first row in the page
  }

  repeated uint64 buffer_offsets = 3;     // column-level buffers
  repeated uint64 buffer_sizes   = 4;
}

As can be seen, each ColumnMetadata contains an array of Page messages. The key fields of each Page are:

  • buffer_offsets and buffer_sizes: the absolute offsets and lengths of the page’s buffers in the file
  • length: how many rows the page stores
  • encoding: the page layout and encoding, which determines how buffers are organized within the page
  • priority: the row number of the first row in the page

CMO Table #

Immediately after the Column Metadata comes the CMO table, which records the (position, size) of each ColumnMetadata, from which the corresponding protobuf is parsed:

(position u64, size u64) × num_columns
16 × num_columns bytes in total

GBO Table #

Same structure as the CMO:

(position u64, size u64) × num_global_buffers
  • GBO[0] points to GB[0] (the FileDescriptor);
  • GBO[1..] point to arbitrary byte blocks attached via add_global_buffer (IVF metadata, zone maps, etc. in index files).

Finally, there is the fixed-length Footer, which stores the metadata of the whole file:

Offset from end Size Field
−40 8 column_meta_start
−32 8 column_meta_offsets_start
−24 8 global_buff_offsets_start
−16 4 num_global_buffers
−12 4 num_columns
−8 2 major_version
−6 2 minor_version
−4 4 "LANC"
  • All are little-endian unsigned integers;
  • Fixed at 40 bytes, and is not a protobuf;
  • It is placed at the tail rather than the head because, at write time, the offsets of each region are only known after all pages and metadata have been written; the cost is that reading the file requires seeking to the last 40 bytes first.

Both CMO and GBO store (position, size) rather than just position, because each entry is a variable-length protobuf or an arbitrary byte block whose length cannot be derived from its position.

Summary of the File Structure #

We have now analyzed the structure of the data file; here is a summary of its components:

Region Size Fixed-length
Data Pages depends on the data No
GB[0] (schema) protobuf serialized length No
Column Metadata one protobuf per column No
CMO 16 × num_columns Yes
GBO 16 × num_global_buffers Yes
Footer 40 Yes

Based on this structure, the pseudocode for parsing a data file is as follows:

footer = parse_footer(tail[-40:])
gbo    = parse_table(tail, footer.global_buff_offsets_start, footer.num_global_buffers)
schema = FileDescriptor::decode(read(gbo[0].pos, gbo[0].size))
cmo    = parse_table(tail, footer.column_meta_offsets_start, footer.num_columns)
for i in projected_columns:
    col_meta[i] = ColumnMetadata::decode(read(cmo[i].pos, cmo[i].size))

Using the offset of GB[0], the file can be divided into several intervals:

[0,                     GB[0].pos)                       → Data Pages
[GB[0].pos,             GB[0].pos + GB[0].size)          → GB[0] (FileDescriptor)
[column_meta_start,     column_meta_offsets_start)       → Column Metadatas
[column_meta_offsets_start, global_buff_offsets_start)   → CMO   (16B × N)
[global_buff_offsets_start, file_len - 40)               → GBO   (16B × GN)
[file_len - 40,         file_len)                        → Footer

Note that GB[0].pos + GB[0].size == column_meta_start: GB[0] sits immediately before the column metadata. But GB[1..] are written in place and may fall within [0, GB[0].pos), so the “Data Pages” interval actually contains them as well.

Parquet File Structure #

The above introduced the structure of Lance data files; next we compare the optimizations Lance makes relative to Parquet. Before that, let’s briefly look at Parquet’s file structure to understand its strengths and weaknesses.

Parquet’s data file layout looks roughly like this:

Parquet file structure: row group / column chunk / page

We can see that:

  • A Parquet file consists of multiple row groups.
  • Each row group contains the data of multiple columns.
  • The data of each column is further composed of multiple pages.
  • Among these components, the row group and the column data are logical components; the physical unit that actually stores data is the page. Each page is preceded by a PageHeader (Thrift) recording the page’s type, encoding, compressed and uncompressed sizes, etc.; the schema and file version are not here, but in the FileMetaData at the end of the file.

In Parquet, the data page is the compression boundary: each page can be encoded and decoded independently, so Parquet can adopt “opaque encodings” with higher compression ratios within pages.

It is necessary here to explain and compare “transparent encoding” and “opaque encoding”.

Transparent and Opaque Encodings #

The so-called transparent encoding: the compressed data remains 1:1 locatable value by value. It has the following characteristics:

  • Still fixed-width after compression (or with fixed-width offsets), so the position can be computed directly from i
  • No cross-value dependencies (value[i] does not depend on value[i-1])
  • No shared mutable state (no reliance on “scan history” to reconstruct)

In other words, the reader can directly compute “the position of the i-th value in the compressed data” and decode that single value alone. This distinction matters greatly for random access: to fetch the i-th value with an opaque encoding, the preceding data from 0..i must first be decoded sequentially. The comparison between the two:

  • Transparent: position of value[i] = known formula → single-value decode → touches no other values
  • Opaque: position of value[i] = must first decode [0..i) → serial

The transparency of common encodings is summarized below:

Encoding Fixed-width? Cross-value dependency? Verdict
Flat Yes No ✅ Transparent
Variable (offsets + data) offsets fixed-width No ✅ Transparent
Fixed-bit-width Bitpacking Yes No ✅ Transparent
FSST Yes (fixed-width code + symbol table) No ✅ Transparent
Constant 0 bytes No ✅ Transparent
ByteStreamSplit Yes (byte-stream split) No ✅ Transparent (but often followed by block compression)
RLE No (variable run lengths) Yes ❌
Delta No Yes ❌
Whole-block general compression (zstd / snappy / lz4) No Yes ❌

A few of them are explained below:

Why RLE is opaque

encoding: [(value=7, run=1000), (value=3, run=1), ...]

To fetch the 1001st value:

must walk through the first run
→ only then know where the second run starts
→ the position is not computable, it can only be "scanned" out

Why Delta is opaque

v[0] = base
v[i] = v[i-1] + delta_i
fetching v[1000] → must accumulate 1000 times starting from v[0]

Why ByteStreamSplit itself is transparent

an f32 is split into 4 streams by byte
fetching v[i] only requires jumping to the i-th byte in each of the 4 streams

The reason it is often classified as “opaque” in Parquet is not the splitting itself, but the fact that it is always followed by a layer of whole-block general compression — once zstd is applied, it degenerates into the non-locatable form below.

Why whole-block zstd / snappy is opaque

compressed block = [literal][back-reference][literal][back-reference]...
to decode the i-th byte, all back-reference copies must be executed sequentially from the start of the block

Note that it is “whole-block compression” that is opaque. If each value is compressed in its own frame (per-value), the position of the i-th value is still computable — this is exactly what Lance does when handling extremely long values.

Why Bitpacking is transparent instead

1024 values, 13 bits each
byte_offset(i) = i * 13 / 8

As long as the bit width is fixed for each block, single-value location holds.

Why FSST is transparent

FSST = symbol table + fixed-width code stream
every 8 original bytes → 8 codes (1 byte each)

The position of a code is computable, and decoding only requires looking up the symbol table, so it is transparent.

The cost of transparency:

Transparent Opaque
Single-value location O(1) O(i) or decode the whole block
Compression ratio Low High
Available encodings flat / variable / bitpack / fsst / per-value general + rle / delta / block zstd

Back to Parquet: since the data page is the compression boundary, Parquet can choose opaque encodings with higher compression ratios, at the cost of giving up “single-value locatability” — random access must decompress the whole page first.

Optimized for Sequential Scans #

Here are several typical examples of sequential scans:

Example 1: data warehouse aggregation reports

SELECT region, sum(amount), count(*)
FROM sales
WHERE ts >= '2026-01-01'
GROUP BY region;

Example 2: feature engineering / training set export

tbl = pq.ParquetDataset("s3://bucket/features")
df = tbl.to_table(columns=["user_id", "embedding", "ctr"])
df.write_parquet("s3://bucket/export")

Example 3: full-table validation / statistics

SELECT count(*), min(ts), max(ts), count(distinct user_id) FROM events;

The common points of these examples:

  • The output is small (aggregation results / a few columns)
  • The input is large (the whole table or whole partitions)
  • The scan ratio is > 10%, usually close to 100%
  • Nobody cares “where row 3 is”; they only care “how long a full pass takes”

The last point is decisive: the order between rows does not matter; only the total byte count matters.

Sequential scans (full scan / column scan) refer to:

  • Reading entire columns (or an entire row range) in order, in blocks,
  • evaluating conditions row by row while reading,
  • without knowing in advance “which rows will match”.

Parquet’s optimizations for sequential scans (especially analytical full-table / large-range scans) can be examined along three lines: “storage layout”, “encoding and compression”, and “metadata skipping”.

Storage Layout: Keeping Disk I/O as Sequential as Possible #

Hybrid row-column layout (Row Group + Column Chunk): the file is horizontally split into Row Groups (parquet-mr defaults to 128MB; 512MB–1GB is common in production), and within a Row Group data is stored by column, each column being a contiguous Column Chunk. This means:

  • When scanning a few columns, what is read is large contiguous blocks of data in the file, rather than reading a row and skipping unneeded fields as in row storage. In the era of mechanical disks this reduced seeks; in the era of SSDs/object storage it naturally matches read-ahead and large GETs.
  • Row Groups are large enough that a single sequential read has a large granularity, amortizing open/seek/request counts — especially critical for high-latency storage such as HDFS and S3.
  • With column pruning (projection pushdown), unneeded Column Chunks are not read at all.

Page organization (Page): a Column Chunk is further divided into Pages of about 1MB, and the Page is the smallest unit of encoding and compression. The decoder can decompress and decode in a pipelined fashion page by page, keeping memory usage under control, and it also makes it easy for readers to do cross-page read-ahead and I/O coalescing (implementations such as Arrow and Parquet-MR all have coalescing optimizations that merge multiple small logical reads into large sequential reads).

Encoding and Compression: Fewer Bytes + Vectorization-Friendly #

The bottleneck of sequential scans is usually I/O bandwidth, so Parquet tries to compress data as small as possible and make it “scan-friendly” at the encoding level:

  • Dictionary encoding: low-cardinality fields (such as status or enums) are stored as a dictionary + integer indices, and during scans many filters can even be applied directly on the dictionary.
  • RLE / Bit-packing: repeated values and integer indices are stored with runs + compact bit widths, yielding extremely high compression ratios on sorted or low-distinct-count columns, and decoding is naturally suited to batch/vectorized (SIMD) expansion.
  • Delta encoding: monotonically increasing sequences such as timestamps and auto-increment IDs store only the differences.
  • Block compression (Snappy/Zstd/LZ4): compression at the Page level buys fewer bytes from disk during scans. The choice of a light compressor like Snappy is itself a trade-off that “yields to throughput” — the CPU decoding cost is far lower than the I/O saved.

The overall effect: a sequential scan may read only 1/5 or even fewer of the bytes of the original data.

Metadata: “Skip When You Can” During Scans #

A sequential scan does not mean every byte must be read; Parquet uses hierarchical statistics to support skipping:

  • Footer: the Thrift metadata at the end of the file records column statistics for all Row Groups (min/max/null_count, total byte size, encodings, etc.). With a single tail seek to read the footer, the reader can plan the whole scan — which Row Groups are excluded by predicates, which Column Chunks to read, and where the offsets are.
  • Column Index / Offset Index (introduced in parquet-format 2.5, supported since parquet-mr 1.11): refine statistics down to the Page level; combined with the Page offset table, they can skip individual data pages, which works extremely well on sorted data (e.g., scanning a time window after sorting by time).
  • Execution shape of predicate pushdown: read the pages of the filter columns first, use them to cut down the candidate row ranges, and then apply late materialization on the projected columns, avoiding reading entire rows only to discard them.

Summary #

Layer Design Benefit for sequential scans
Layout columnar + large Row Groups + contiguous Column Chunks large contiguous I/O, column pruning
Page ~1MB Page as the decode/compression unit streaming decode, I/O coalescing
Encoding dictionary, RLE/Bit-packing, Delta fewer bytes, vectorized decoding
Compression Page-level Snappy/Zstd reduced I/O bandwidth consumption
Metadata Footer statistics, Column/Offset Index Row Group/Page-level skipping

The core idea in one sentence: sacrifice fine-grained random access in exchange for “reading only what is needed, all in large contiguous I/O, and skipping whatever can be skipped via statistics”. This is also why Parquet suits OLAP scans, while point-lookup workloads need additional indices or a row-storage layer.

Example #

Suppose a table with 20 columns and 1 billion rows in total; logically it has:

1 billion rows × 20 columns ≈ 200 GB (logical, uncompressed)

Query:

SELECT region, sum(amount) FROM sales
WHERE ts >= '2026-01-01' GROUP BY region

Columnar storage takes the first cut

20 columns → read only 3 columns (region / amount / ts)
assume these 3 columns take 30 B/row
→ 30 GB logical

A 6.7x reduction — this step is done by columnar storage and has nothing to do with row groups.

Compression takes another cut

homogeneous data (region low-cardinality, amount well-distributed, ts monotonic)
+ delta / RLE / dictionary / zstd
→ about 4x
→ 30 GB → 7.5 GB physical

Row group statistics skip a bit more

1 GB row groups → 200 of them
each row group records min/max on ts → skip the 30% of row groups that cannot match
→ 5.25 GB physical

In total:

200 GB raw
→ 30 GB (column pruning)
→ 7.5 GB (compression)
→ 5.25 GB (statistics skipping)
total reduction: 38x

Poor Point-Lookup Performance #

However, Parquet’s design is not friendly to point lookups. Take a point-lookup query like this:

SELECT * FROM sales WHERE id = 12345678;

The access path to the Parquet file becomes:

1. read the footer (a few MB)
2. read the metadata of 3 column chunks
3. read the dictionary page
4. locate 1 page (1 MB)
5. decompress the whole page
6. decode levels to walk to that row
7. fetch 200 B
read ~1 MB to get 200 B
read amplification 5000x

The root cause is that Parquet’s file design is optimized for sequential scans. A sequential scan has only two items on its ledger: total bytes and request count. Every design choice in Parquet presses down on these two:

  • columnar storage → read fewer columns
  • 1 MB pages → send fewer requests
  • opaque encoding + block compression → read fewer bytes
  • statistics pruning → read even less

The cost is “no locatability within a page”, but as long as the hit ratio is high, this cost is amortized to the point of being negligible.

Why Lance Needs to Optimize for Random Access #

Parquet can afford this cost because its main scenario is analytical scanning: a single query routinely sweeps millions of rows, and the read amplification of an occasional point lookup is amortized by the overall throughput. The workloads Lance faces are not of this kind.

Index Row Fetching #

Vector search, full-text search, and scalar indices share a common shape: first use the index to obtain a batch of row addresses, then go back to the table by those addresses to fetch the original data.

query → index → [row_addr, row_addr, ...] → row fetch → results

A top-k query usually returns only tens to hundreds of rows, yet they are scattered across the entire file or even multiple fragments. This step is inherently random, and it is on the critical path of every index query — no matter how fast the index is built, slow row fetching means slow full-text search and slow vector search overall.

The row address itself is also designed for this:

row_address = (fragment_id << 32) | local_row_offset

Given an address, bit operations alone can split out the fragment and the row offset, with no lookup table needed.

Random Sampling During Training #

Machine learning training needs to shuffle the dataset into batches:

one epoch: N batches, each batch randomly sampling B rows
each row may come from a different fragment or a different page

Shuffling is not an optional optimization. If samples within a batch are correlated, gradient quality suffers, so randomness is part of the training semantics. If fetching one row takes 1 MB, the GPU will idle waiting for I/O — this is also the direct reason why Lance emphasizes high GPU utilization.

Object Storage Turns Read Amplification into Latency and Bills #

The same read amplification costs completely differently on local disks versus object storage:

Local disk Object storage
Reading 1 MB extra a few milliseconds the fixed latency of one GET (tens of milliseconds)
Billing not metered billed by request count + traffic
Throughput high limited per stream, needs concurrency to amortize

Fetching 200 B while paying for 1 MB of traffic and latency shows up directly as cost and P99 in serving scenarios. Especially when dozens or hundreds of point lookups run concurrently, read amplification multiplies.

The Two Workloads Have Different Shapes #

The two kinds of scans have different characteristics:

  • Analytical scans: read a lot, but contiguously → the bottleneck is sequential throughput
  • Index row fetching / training sampling: read little, and scattered → the bottleneck is bytes per request

Lance’s target workloads lean toward the latter. Sequential scans are of course still the bulk of most queries, but if only sequential scans are optimized for, index row fetching and training sampling will be choked by the file format itself — and these two happen to be the core paths of the AI data stack.

So the problem becomes a constraint that must be satisfied simultaneously:

  • Sequential scans want pages large enough (to amortize I/O and metadata overhead)
  • Random access wants a read granularity small enough (to control bytes per request)

Parquet uses the single unit of “page” to serve both purposes, so it can only compromise. Lance’s answer is to split it into two layers — which is what the next section is about.

Lance’s Optimizations over Parquet #

Compared with Parquet, Lance’s data file format design has two main changes:

  • Row groups are removed; each column is paginated independently
  • Locatable structures (MiniBlock / FullZip) are introduced within pages, bringing random access down to byte ranges

The following explains them in detail.

Removing the Row Group #

The row group is a design specific to Parquet: a Parquet file is split into multiple row groups, each containing a segment of data for every column. Take a table with columns id, name, and embedding as an example; suppose the row group is set to 1 million rows, its physical structure is as follows:

Parquet file
├── RowGroup 0            ← one horizontal cut: rows 0 ~ 999,999
│   ├── ColumnChunk: id        (the id of these 1 million rows)
│   ├── ColumnChunk: name      (the name of these 1 million rows)
│   └── ColumnChunk: embedding (the embedding of these 1 million rows)
├── RowGroup 1            ← rows 1,000,000 ~ 1,999,999
│   ├── ColumnChunk: id
│   ├── ...
└── ...

In the example above, the data model looks roughly like this:

RowGroup {
  num_rows: 1_000_000
  columns: [
    ColumnChunk { column: id,        num_values: 1_000_000 },
    ColumnChunk { column: name,      num_values: 1_000_000 },
    ColumnChunk { column: embedding, num_values: 1_000_000 },
  ]
}

The problem with this design is: the RowGroup is cut at row 1,000,000 — in other words, all columns in the same row group must cover exactly the same row range.

This design causes the following problems:

The Row Count Is Held Hostage by the Widest Column #

A Parquet row group’s size is controlled by bytes (parquet-mr defaults to 128MB), but the number of rows it covers is determined by the full row width, and all columns share this row count. Consider two columns:

  • embedding = fixed_size_list<float32, 1024> = 4096 bytes/row
  • id = 8 bytes/row

A whole row is about 4.1 KB, so a 128MB row group contains only about 32K rows:

embedding chunk = 32K × 4096B ≈ 128 MB
id        chunk = 32K × 8B    ≈ 256 KB   ← the narrow column is left with only a crumb

Conversely, to make the id chunk reach about 8MB (one page), the row group must be enlarged to 1 million rows; at that point the embedding chunk becomes 4 GB, and the write side has to buffer a huge amount of data for this single row group (many implementations fall back to spilling to disk, but at the cost of write amplification).

In other words, the row count a narrow column needs and the row count a wide column can afford differ by orders of magnitude, yet they are forced to share a single value.

The Lower Bound of Read Amplification Is the “Page”, Not the Chunk #

Two concepts need to be distinguished here:

  • chunk: all the data of one column within one row group; size = row group row count × the column’s per-row width
  • page: a block further cut out of a chunk by bytes, about 1 MB by default

A point lookup reads a page: locate the page containing the target row, read about 1 MB, and decompress the whole page. So the read amplification factor ≈ page_size / row_size, independent of the chunk size. At the format level, the page size is recorded per page and is not directly pinned by the row group’s row count (some implementations support configuring page sizes per column).

What is truly bound by the row group is two other things:

  1. The granularity of statistics pruning: the min/max in the footer are at the row group level; to get down to the page level, Column Index / Offset Index must be written additionally (optional, and many writers do not enable them).
  2. Splitting and parallelism: the row group is naturally the unit of task division and file splitting; when the row count is inappropriate, narrow columns end up with nothing but runt pages while wide columns eat up memory.

Small Row Groups → Runt Pages #

Conversely, shrinking the row group:

  • At 10K rows, the id chunk = 10K × 8B = 80 KB; at 1K rows, only 8 KB;
  • at this point a narrow column’s page may be only a few KB — this is the so-called runt page (an underdeveloped small page);
  • a single I/O on cloud storage has fixed overhead (latency, per-request billing, throughput floor), so reading pages of a few KB is extremely uneconomical, and sequential scans degenerate into a massive number of small requests.

Thus a dilemma arises:

  • Small row group → few rows; a narrow column’s entire chunk is only tens or even a few KB, and cutting pages out of it yields runt pages;
  • Large row group → to accumulate enough bytes for narrow columns, the row count must grow, and the wide column’s chunk inflates by the same multiple, which the write side must buffer for the whole group.

No matter how you tune it, the demands of narrow and wide columns are tied to the same row count.

Lance’s Approach #

For the reasons above, Lance removes the row group and keeps only the “page”: each column is paginated independently, each page stores data of a single column, and the page size is computed from the column’s own byte budget — by default the writer cuts a page after accumulating about 8 MiB per column (data_cache_bytes is tunable), completely independent of other columns. Only then can Lance support partial page reads:

  • Each page records the row number of its first row (priority), so reading a row range first locates the page;
  • intra-page encodings (MiniBlock / FullZip / Sparse) allow decoding to start from the middle of a page;
  • the metadata gives precise buffer offsets/sizes, so a single range GET suffices.

Optimizing Random Access #

Lance’s random access capability is built on “locatability within a page”. Let’s first look at the role removing the row group plays here, then at several mechanisms inside the page.

Removing the Row Group: Making “Large Pages” and “Small Point-Lookup Reads” No Longer Mutually Exclusive #

A point lookup never reads the entire chunk, but a page: it locates the page by row number in the column metadata, reads about one page’s worth of bytes, and decompresses it. How large the chunk is does not affect the bytes read in this operation.

What truly determines the read size of a point lookup is the page size. And in Parquet, the page is simultaneously the encoding unit, the compression unit, and the I/O unit — all three are locked together:

Parquet: minimum point-lookup read = page size
        to read less per point lookup → pages must be small
        smaller pages → smaller compression window, higher page-header share → worse sequential scans
        so a compromise is inevitable, typically 1 MB

In other words, Parquet’s lower bound of point-lookup amplification is pinned at the 1 MB level by “compression ratio”; pushing it further down would make sequential scans pay the price.

And the row group makes this constraint even harder to bypass. chunk size = row count × the column’s per-row width, and all columns in the same row group have exactly the same row count, so a narrow column’s chunk can be only a few hundredths of a wide column’s:

128 MB row group ≈ 32K rows
→ embedding chunk ≈ 128 MB, id chunk ≈ 256 KB
→ page size cannot exceed chunk size: the narrow column cannot even fit a 1 MB page
→ to give the narrow column large pages too, the row group must take more rows
→ the wide column's chunk inflates by the same factor

In other words, the page size — a parameter that should be decided per column — is forced to compromise on the single number of “rows per group”.

After Lance removes the row group, the page size can be determined purely by I/O economics and independently per column, and the point-lookup granularity no longer equals the page size:

Lance: page  ≈ 8 MB     → sequential scans amortize I/O and metadata overhead
       chunk ≈ 4 KB     → point lookups read only the hit chunk

Large pages do not prevent point lookups from reading little, and the compression window of a chunk is not so small as to hurt the compression ratio. The role of removing the row group here is to lift the constraint that “the page size must also serve random access”.

A side benefit is that each column’s page count is completely independent (column A has 3 pages, column B has 17 pages, column C has 1 page): narrow columns no longer have to be squeezed into runt pages to accommodate wide columns, and wide columns are no longer size-limited to accommodate narrow ones.

What compresses the point-lookup read from 1 MB to 4 KB is the chunk index in the next section; removing the row group makes “large pages + small chunks” possible at the same time. Only with both combined do we get the numbers in the point-lookup comparison later.

message Page {
  uint64 length = 3;
  uint64 priority = 5;   // row number of the first row in this page
}

The page table is naturally ordered by priority, so a single binary search with partition_point finds the intersecting page.

Parquet either relies on the optional OffsetIndex or scans the variable-length Thrift page headers from the beginning.

Splitting Chunks Inside the Page: Buffer 0 #

A MiniBlock page puts the “index” and the “data” in different buffers (with a dictionary or list, there are additional buffers such as the dictionary and the rep index):

buffer 0  one 2–4 byte index word per chunk
buffer 1  all chunks packed back to back

The index word encodes two things: how many 8-byte words this chunk occupies, and how many values the chunk contains (expressed as log2):

word = ((chunk_bytes / 8 - 1) << 4) | log2(num_values)

At initialization, the reader loads buffer 0 entirely into memory (each chunk takes only 2–4 bytes), uses a prefix sum to compute which chunk k the r-th row falls into, and then uses chunk_bytes to get its exact byte range in buffer 1 — at random access time, only that single chunk needs to be read.

Whereas a Parquet page is a single inseparable compressed block, with no locating structure inside the page.

The buffer layout of MiniBlock (index, rep/def, and values stored separately) and the exact format of the chunk header are not expanded here.

The Choice of Compression Encodings Is Constrained by “Locatability” #

  • Parquet: can use opaque compressions such as delta / RLE / BSS / whole-block zstd, achieving high compression ratios, at the cost of having to decompress the entire page every time.
  • Lance: MiniBlock is chunk-level compression, and RLE / BSS / zstd can still be used within a chunk; but FullZip (a value-level interleaved layout) enforces per-value transparency — after compression, the position of the i-th value must still be computable.

Therefore Lance’s FullZip usually has a lower compression ratio; the compensation is “per-value zstd when a single value ≥ 32 KiB” — each value is compressed in its own frame, so positions remain computable.

Deletions Go Through Bitmaps, Not Rewrites #

This one goes beyond a single data file and belongs to the dataset-level design, but it directly determines “how much deleting a row costs”:

  • The Parquet format itself has no deletion semantics; deleting a row requires the engine to read-modify-write the entire row group (across columns).
  • Lance records deleted rows with bitmaps under _deletions/, leaving the data files untouched. The cost of deleting a row drops from rewriting an entire row group to writing one small file.

Metadata Can Be Fetched per Column #

  • Parquet: all metadata is concentrated in the Footer, which must be read in full when opening the file; its size is O(row_groups × columns).
  • Lance: metadata is scattered across the CMO / GBO, 16 bytes per column, and only the metadata of projected columns needs to be read — with wide tables and narrow projections, the difference in file-open cost is significant.

A Point-Lookup Comparison #

Based on the data file structures of Parquet and Lance, the flow of a point lookup compares as follows:

Parquet:
  read the footer (a few MB)
  → locate the row group
  → read the dictionary page
  → scan page headers or consult the OffsetIndex
  → read a 1 MB page
  → decompress the whole page
  → decode levels to walk to the target row
  → fetch 200 B          read amplification ≈ 5000x

Lance:
  look up the manifest for fragment → file (0 I/O)
  → Page.priority binary search (in memory)
  → consult buffer 0 (already cached at initialization)
  → read the hit chunk (~4 KiB)
  fetch 200 B            read amplification ≈ 20x

Lance’s read amplification has not disappeared; it has only shrunk from “a whole 1 MB page” to “one 4 KiB chunk”. What really needs attention is not making the chunk too large — this is also why MiniBlock keeps chunks within 32 KiB.

The characteristics of the two:

  • Parquet’s random access is “locate the page first, then decompress the whole page”;
  • Lance’s random access is “locate the byte range layer by layer, and read only the small hit chunk”.

The Costs #

Lance is not “strictly better”; it “trades for a different set of costs”:

Cost Description
Lower compression ratio FullZip must stay transparent; no delta / whole-block zstd
More complex metadata multiple layers: CMO / GBO / PageInfo / ChunkIndex / rep index
More complex scheduling requires its own FieldScheduler / PageScheduler
Slightly slower sequential scans fragmented decompression granularity (4 KiB vs 1 MB), fewer large-block SIMD opportunities
Extra file types _deletions/, _indices/

Summary #

Putting the two structures side by side, the difference comes down to one sentence:

  • Parquet: row group → column chunk → page (not locatable within a page)
  • Lance : column → page → buffer (locatable down to the chunk within a page)

Lance removes the cross-column shared row group, letting each column paginate by its own byte budget; then, inside the page, it uses the chunk index in buffer 0 to bring random access down to concrete byte ranges.

The two sides are two different trade-offs, with no absolute winner:

  • Parquet trades read amplification for compression ratio and sequential throughput;
  • Lance trades metadata complexity and compression ratio for fewer bytes per random access.

A rough criterion is the hit ratio:

hit ratio > 5%–10%  → sequential scan, Parquet wins
hit ratio < 1%      → random access, Lance wins

The three intra-page layouts (MiniBlock, FullZip, Sparse) have many details and will be expanded in separate later articles.

References #