PREP WITH PROOF
Menu
DATA ENGINEERING / PRACTICAL GUIDE

Parquet Partition Pruning vs Row-Group Pruning

Compare Parquet partition pruning, row-group statistics and column projection with a runnable PyArrow lab using ordered, mixed and statistics-free files.

THE QUICK ANSWER

Partition pruning rules out files using partition values. Row-group pruning rules out groups inside candidate Parquet files using metadata such as column ranges. Rows in retained groups still need filtering. The same query can return identical rows while retaining very different amounts of candidate data.

A filter can return fewer rows without skipping much data

A query selects three events from one region, yet reading its Parquet dataset still feels expensive. The filter may be correct while the file layout gives the reader little opportunity to avoid work. To investigate, separate three decisions: which files can be excluded, which row groups inside the remaining files can be excluded, and which rows still need to be filtered after reading.

Partition pruning uses known partition values, often encoded in directory paths such as region=east. Row-group pruning uses metadata inside a Parquet file, such as column minimum and maximum values, to rule out groups that cannot match. Column projection is a separate choice: it asks the reader for selected columns rather than all of them. A predicate may also require a column even when that column is absent from the final output.

These are opportunities for the reader, not guarantees about every engine or expression. A source filter passed to a dataset scanner can enable pruning. Filtering a fully materialized table afterward cannot retroactively avoid the read that produced it. Start by checking where the predicate is applied, then inspect the metadata that could support it.

Source: Apache Arrow Dataset: filter pushdown, partition expressions and projection ↗

Files, row groups and projected columns have different jobs

A Parquet row group is a horizontal set of rows, with a column chunk for each column. A file can contain several row groups. A Hive-style partition directory provides another layer outside the file: a reader configured for that partitioning can derive a field value from the directory name, even if the field is not physically stored in the file.

Consider two files, one for east and one for west. Each stores event IDs 0 through 11 in three row groups. A filter for east and event_id >= 9 first rules out west using the partition expression. If the east file is ordered by event_id, its first two groups have maxima below 9 and can also be ruled out. The last group remains a candidate, but its row with ID 8 still does not match the predicate.

This is why a surviving group is not a set of proven matches. A minimum and maximum bound can show that a match is impossible, but overlapping bounds generally leave uncertainty. If each group mixes small and large IDs, every group can overlap the requested range while still yielding only three rows overall.

LayerEvidence in this exampleWhat it establishes
PartitionDirectory-derived region valueThe west file cannot satisfy region = east
Row groupevent_id statisticsA group with max < 9 cannot satisfy event_id >= 9
Row filterValues in retained groupsWhich individual rows actually match
ProjectionRequested output columnsWhich fields are returned; filter columns may still be needed

Source: Apache Parquet: file, row-group and column-chunk structure ↗

Run a three-layout comparison with PyArrow

Create a Python environment with PyArrow available. This example was run with PyArrow 23.0.1; it uses the Dataset API and writes its own files in a temporary directory. It compares ordered IDs, deliberately mixed IDs, and ordered IDs written without statistics. The files contain identical logical events, and each file has three row groups of four rows. The temporary files are removed when the block ends.

get_fragments with the predicate inspects candidate files. split_by_row_group inspects which row groups remain candidates under the filter. Passing the dataset schema matters here because region is a virtual partition field and does not appear in the physical file schema. The final to_table call applies the same filter and projects only region and event_id.

The assertions check both the expected metadata decisions and the returned values. The printed counts are candidate file and row-group counts, not a measurement of storage requests or bytes transferred. A reader can still need directory listings, metadata reads and other setup work before it knows what to skip.

from pathlib import Path
from tempfile import TemporaryDirectory
import pyarrow as pa
import pyarrow.dataset as ds
import pyarrow.parquet as pq

with TemporaryDirectory(prefix="parquet-pruning-") as tmp:
    root = Path(tmp)
    orders = {
        "ordered": list(range(12)),
        "mixed": [0, 1, 2, 9, 3, 4, 5, 10, 6, 7, 8, 11],
        "no_stats": list(range(12)),
    }
    for layout, ids in orders.items():
        for region in ("east", "west"):
            folder = root / layout / ("region=" + region)
            folder.mkdir(parents=True)
            table = pa.table({
                "event_id": pa.array(ids, type=pa.int64()),
                "payload": ["example-" + str(i) for i in ids],
            })
            pq.write_table(
                table, folder / "part.parquet",
                row_group_size=4,
                write_statistics=(layout != "no_stats"),
            )

    predicate = (ds.field("region") == "east") & (ds.field("event_id") >= 9)
    for layout in orders:
        dataset = ds.dataset(root / layout, format="parquet", partitioning="hive")
        all_files = list(dataset.get_fragments())
        candidates = list(dataset.get_fragments(filter=predicate))
        assert len(all_files) == 2 and len(candidates) == 1
        fragment = candidates[0]
        groups = list(fragment.split_by_row_group(filter=predicate, schema=dataset.schema))
        retained = [rg.id for group in groups for rg in group.row_groups]
        result = dataset.to_table(columns=["region", "event_id"], filter=predicate)
        assert sorted(result.column("event_id").to_pylist()) == [9, 10, 11]
        assert set(result.column("region").to_pylist()) == {"east"}
        assert result.column_names == ["region", "event_id"]
        expected = [2] if layout == "ordered" else [0, 1, 2]
        assert retained == expected, (layout, retained)
        print(layout, "files:", len(all_files), "->", len(candidates),
              "row groups:", retained, "matching rows:", result.num_rows)
    print("PyArrow", pa.__version__)

Source: Apache Arrow ParquetFileFragment: split_by_row_group and schema ↗

Interpret the result without turning it into a benchmark

In the tested environment, all three layouts select one of the two files and return IDs 9, 10 and 11. The ordered layout retains row group 2. The mixed and no_stats layouts retain groups 0, 1 and 2. These group IDs are zero-based within the candidate file.

In the mixed layout, the first group contains ID 9, the second contains 10 and the third contains 11. Every group therefore has a possible match, so none can be discarded by the range predicate. In no_stats, the reader cannot use the omitted column statistics to prove that the early groups cannot match. Partition pruning still works because its evidence comes from the directory layout.

Do not convert one retained group out of three into a claim of exactly two-thirds less I/O. Column sizes, compression, metadata reads, filesystem behavior and reader prefetch can affect the actual work. A tiny local fixture also says little about object-store request latency or a production engine’s scan behavior. Use these counts to explain the mechanism; measure your real workload separately.

ordered files: 2 -> 1 row groups: [2] matching rows: 3
mixed files: 2 -> 1 row groups: [0, 1, 2] matching rows: 3
no_stats files: 2 -> 1 row groups: [0, 1, 2] matching rows: 3
PyArrow 23.0.1

Source: Apache Arrow ParquetFileFragment: split_by_row_group and schema ↗

Inspect the row-group bounds before rewriting files

To diagnose a real file, inspect whether the relevant column has statistics and whether its range is selective for the predicate. Adapt this snippet to a Parquet file you can read. It finds event_id by its Parquet path rather than assuming it is always column zero. For nested schemas, identify the correct physical column path.

If each group has a very wide range, sorting or clustering by a commonly filtered field may make the bounds more useful. If statistics are absent, check the writer configuration and the files it actually produced. The existence of a statistics object is still not a promise that every min/max value or type supports your intended optimization; inspect the available fields and test the reader’s behavior.

import pyarrow.parquet as pq

metadata = pq.ParquetFile("path/to/part.parquet").metadata
for group_id in range(metadata.num_row_groups):
    group = metadata.row_group(group_id)
    for column_id in range(group.num_columns):
        column = group.column(column_id)
        if column.path_in_schema != "event_id":
            continue
        stats = column.statistics
        bounds = (
            (stats.min, stats.max)
            if stats is not None and stats.has_min_max else None
        )
        print(group_id, "rows:", group.num_rows, "bounds:", bounds)

Source: Apache Arrow: reading and writing Parquet files and metadata ↗

When pruning does not happen, check the failed layer

If both regions remain candidate files, confirm that you opened the dataset with the intended partitioning and that the predicate uses the inferred field and type. A raw file read does not automatically imply the same virtual columns as a Hive-partitioned dataset. Directory discovery is also different from reading file contents: excluding a partition from a scan does not imply that no listing operation occurred.

If the right file is selected but all its groups remain, inspect statistics and layout. A large row group that spans the whole ID range has less opportunity to be excluded for a narrow range filter. Smaller groups can improve granularity but bring more metadata and can affect compression or throughput. Choose sizes through representative measurements rather than minimizing the row count per group.

If a query returns the right rows yet reads unexpectedly much data, verify that the predicate reaches the storage reader in a form it can use. An expression wrapped in a transformation may be harder to relate to stored bounds than a direct field comparison. Compare the original expression with an equivalent, supported source predicate while asserting identical results. Do not change query meaning merely to obtain a more attractive scan plan.

If the plan reports pruning but elapsed time stays high, inspect the remaining costs. A dataset with many tiny files may spend substantial time on discovery and opening files. A projected column with large values may dominate the remaining reads. Cache warmth can also make two runs look different. Keep output correctness, plan evidence, read metrics and wall time as separate observations.

Source: Apache Arrow Dataset: filter pushdown, partition expressions and projection ↗

Choose layout for the filters your workload actually uses

Partitioning works well when common filters can eliminate whole directory groups without creating an unmanageable number of tiny partitions. Row-group statistics complement that layout when another filter is selective within a partition. Ordering by event_id helped the example because event_id was the filtered range. It would not automatically help a workload filtering an unrelated, randomly distributed field.

For a production comparison, keep the logical rows, predicate, projected columns and reader version fixed. Record candidate files and row groups, inspect the engine’s available scan metrics, and time representative cold and warm runs separately where practical. Verify the returned values after every layout change. The useful conclusion is which layer eliminated work for your workload and what cost remained after it did.

Source: Apache Parquet: file, row-group and column-chunk structure ↗

KEEP THESE THREE THINGS

Your next steps

  1. Check candidate files, retained row groups and returned rows separately.
  2. Inspect statistics and value distribution before changing row-group size or sorting.
  3. Treat pruning counts as evidence of eligibility to skip; measure actual I/O and latency independently.

Sources & official resources

Linked resources checked on 2026-11-12. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →