Skip to main content
Enterprise only
Fragment column statistics store the minimum and maximum value of a column for each fragment. A filtered query uses them to prune fragments: a fragment whose value range cannot match the filter is skipped without being read. Pruning pays off most when the values of the column follow the order in which the data was written, as timestamps usually do. Take a table of 100 million rows written in time order, stored as 100 fragments of 1 million rows each. A filter on a narrow time range matches the range of a single fragment, so the query prunes the other 99 fragments, about 99 million rows, and reads only the remaining 1 million. That is about 100 times less data to read than a scan of the whole table. The statistics reuse the ZoneMap index mechanism, with rows_per_zone of at least 1000000, store_null_bitmap = false and use_seeds = false.

Syntax

No other values are supported. Without WITH, the statement builds an ordinary ZoneMap index, which is not used to skip fragments. The column can be a boolean, integer, floating-point, date, timestamp, string or binary column.

Create the statistics

The statistics are created with a SQL statement. From Python, send the same statement through the SDK’s SQL API.
The statement submits a build job and returns. Follow the job until it succeeds:

Query with a filter

No query change is needed. A filter on the column prunes fragments in both SQL queries and SDK queries.

Check that fragments were pruned

EXPLAIN ANALYZE reports how many fragments remained after pruning:
The plan contains a CoarseZoneMapPruneExec line. candidates=1/100 means that 1 of 100 fragments is read and the other 99 are pruned:
A fragment that has no statistics yet, such as newly written data, is read instead of pruned, so query results stay correct.