Reports, per (part, column, substream) of a MergeTree table, how many compressed blocks use each codec. This is how you observe adaptive codec selection (enabled by enable_adaptive_codec_selection setting), which can pick a codec per block for default-codec columns.
Selecting codec_block_counts reads .bin data files, not just metadata. The other columns are metadata-only.
Parts that do not record their substreams in columns_substreams.txt are not listed.
Every reported value is derived from the table’s data, so reading any column of the result requires the SELECT privilege on all columns of the table. A grant that covers only some of the columns is not enough. The privilege is also required to resolve the structure of the function, e.g. by DESCRIBE. A user who is not allowed to see the table at all, that is, one without the SHOW TABLES privilege on it, gets ACCESS_DENIED whether or not it exists, so the function does not tell such a user which tables exist.
If a row policy applies to the table for the current user, reading codec_block_counts throws ACCESS_DENIED, because the counts would cover rows the policy hides. The other columns stay readable, system.parts_columns reports them regardless of row policies.
Syntax
Arguments
Returned value
A table object with one row per (active part, column, substream) of the source table:
part_name (String) — The active data part the column belongs to.
column (String) — The column name.
substream (String) — The physical stream of the column the counts are for. Matches system.parts_columns.substreams.
data_compressed_bytes (Nullable(UInt64)) — Size of compressed data in the substream, in bytes. NULL for Compact parts.
data_uncompressed_bytes (Nullable(UInt64)) — Size of uncompressed data in the substream, in bytes. NULL for Compact parts.
codec_block_counts (Map(String, UInt64)) — The number of compressed blocks of this substream grouped by codec. Empty for Compact parts, whose columns share one data file and so have no per-stream codec attribution.
Usage example
Column-level totals are a GROUP BY column with sumMap:
A LowCardinality column reports its dictionary and indexes streams separately:
Last modified on September 15, 2026