The idea: a column store in one file
Apache Parquet is a file format for analytics. Spark, Hive, Trino, DuckDB, pandas, BigQuery and Snowflake all read it. It stores a table by column, like the column store in Row store vs Column store, but inside one ordinary file that can sit on a laptop or in object storage such as S3. The file is built so that a reader can find out what is inside cheaply, and then read only the parts a query needs.
Row groups, column chunks and pages
The writer buffers rows until it has a row group, a horizontal slice of the table (here 1,000 rows; real files use about 128 MB to 1 GB, set by parquet.block.size or Arrow's row_group_size). It then writes the row group one column at a time. The values of one column in one row group form a column chunk. A chunk is a list of pages (about 1 MB each, parquet.page.size): an optional dictionary page first, then data pages. A page is the unit that is encoded and compressed (Demo: write the file).
Row groups keep the file usable for very large tables: a writer needs only one row group in memory, and different readers can work on different row groups at the same time.
The footer
The writer only knows where each chunk starts and how big it is after writing it. So the metadata goes at the end: the footer (FileMetaData, encoded with Thrift) holds the schema, the number of rows, and for every column chunk its byte offset, size, encodings and statistics: min, max and the null count. After the footer come its length (4 bytes) and the magic PAR1. A reader starts at the end: it reads the last 8 bytes, learns the footer length, reads the footer, and only then decides what else to read.
Dictionary encoding
A column often repeats a few values. Dictionary encoding stores each distinct value once in the dictionary page and replaces every value by its small integer index. The city chunk has 1,000 values but only 4 distinct cities, so each index needs just 2 bits. Its 9,250 PLAIN bytes become a 37-byte dictionary plus a 253-byte data page (Demo: dictionary + bit-packing).
A writer tries the dictionary first and keeps it only when it helps. In fare every value in a row group is different. The dictionary would be as large as the data, and the indices would only add to it, so the writer falls back to PLAIN, the values one after another (Demo: PLAIN fallback).
The RLE / bit-packing hybrid
The indices are stored with one encoding that mixes two methods. When 8 or more equal indices come in a row, they become an RLE run: a count and the value, once. Otherwise they are bit-packed: 8 indices at a time, each in exactly bit width bits. The day column is sorted, so its indices are 10 runs of 100. They shrink to 10 runs of 3 bytes, and the whole chunk goes from 4,000 bytes to 71 (Demo: dictionary + RLE).
Run-length encoding by itself is shown on Row store vs Column store. Here it works on the dictionary indices, not on the values. After encoding, each page can also be compressed with a codec such as Snappy or ZSTD.
Projection and predicate pushdown
Projection: a query reads only the column chunks of the columns it names. SELECT SUM(fare) reads the three fare chunks, 12,000 bytes, plus 336 bytes of footer and tail. A file written row by row would make it read all 63,750 bytes (Demo: projection).
Predicate pushdown: the reader checks the WHERE clause against each row group's min and max before reading it. For day = 25, row group 0 holds days 1 to 10 and row group 1 days 11 to 20, so neither can contain day 25. Both are skipped without being read. Only row group 2's day and fare chunks are read: 4,407 bytes in all (Demo: predicate pushdown).
| Query | Row groups read | Bytes read |
|---|---|---|
SUM(fare) | 3 of 3 (no WHERE) | 12,336 |
SUM(fare) WHERE day = 25 | 1 of 3 | 4,407 |
COUNT(*) WHERE fare >= 4950 | 3 of 3 (none skipped) | 12,336 |
* WHERE trip_id = 1500 | 1 of 3, all 4 columns | 8,697 |
city, COUNT(*) WHERE day BETWEEN 9 AND 12 | 2 of 3 | 1,058 |
| any query on the row-by-row file | all | 63,750 |
Statistics need sorted data
Min/max only skips data when the values of the filter column are clustered. The file was written in day order, so each row group covers a narrow range of days. fare is spread over every row group: each one has fares from about 500 to over 4,950. So fare >= 4950 cannot skip anything, even though only a few rows match (Demo: filter on unsorted fare). That is why data pipelines often sort or partition by the column that queries filter on most, usually a date. The same idea as zone maps and the sorted files of File organizations.
A Parquet file is written once and never changed in place, so it suits batch loads, not row-by-row updates. Data warehouses on top of it (see the cube in Star schema & OLAP cube) add new files and rewrite old ones in the background, much like the compaction in LSM tree vs B+ tree.
What the page leaves out
The byte sizes are a simplified model: no page headers, no compression codec, a fixed 328-byte footer, and row groups of 1,000 rows instead of hundreds of megabytes. Real writers also differ in small ways (when an RLE run starts, the bit width of a one-entry dictionary). It leaves out nested columns with repetition and definition levels (and so NULLs), other encodings such as DELTA_BINARY_PACKED and BYTE_STREAM_SPLIT, the page index and bloom filters that skip pages inside a chunk, logical types such as dates and decimals, and table formats (Iceberg, Delta Lake, Hudi) that track many Parquet files. MariaDB does not read Parquet files itself; the SQL is the kind that DuckDB, Spark or Trino run on them.
On the mind map
References
Apache Parquet: file format (row groups, column chunks, pages, footer)
Apache Parquet: encodings (PLAIN, dictionary, RLE / bit-packing hybrid)
parquet-format: parquet.thrift (FileMetaData, ColumnChunk, Statistics)
Zeng et al.: An Empirical Evaluation of Columnar Storage Formats (VLDB 2024)