How does a reader of the columnar file format Parquet skip row groups, and when does it skip none?
The footer, written last, holds each row group's column-chunk offsets and min/max stats. A reader reads it and skips row groups whose range can't match the filter. If data isn't sorted on that column, every range spans all values — sort on write.
- Expecting min/max skipping on a column the data is neither sorted nor clustered by
- Thinking the reader must decompress a row group before it can decide to skip it
- Confusing row-group skipping inside a file with directory-level partition pruning
- Why is a low-cardinality column like
device_typefar smaller on disk thansession_id? - How do table formats such as Iceberg use the same statistics to skip whole files?
A Parquet file is split into row groups — horizontal slices of the table. Inside a row group every column has its own column chunk, divided into pages. The footer is written at the end of the file, after the data: it holds the schema, each chunk's offset and min/max statistics per chunk. So a reader reads the footer first and then only the chunks the query needs that can hold matching rows.
A filter WHERE user_id = 42 over two identical files with different row order:
unsorted file sorted by user_id on write
row group user_id min..max row group user_id min..max
0 3 .. 49 998 120 0 1 .. 1 250 000
1 8 .. 49 999 870 1 1 250 001 .. 2 500 000
2 1 .. 49 997 004 2 2 500 001 .. 3 750 000
... ...
→ every range contains 42, → only row group 0 can contain 42,
all 40 row groups are read 39 of 40 are skippedIn the unsorted file the values are shuffled, so every group's range covers almost the whole domain: the statistics are accurate but useless. What helps is sorting or clustering on the filter column at write time (sortWithinPartitions in Spark, a table sort order in Iceberg). Table formats keep the same min/max per file in their manifests and skip whole files before reading any footer — but there, too, skipping works only when the data is ordered.