column_size & column_compressed_size
These functions return the size information of table columns for storage analysis and optimization. Both functions work with the [_META_]
hint to inspect segment file metadata.
column_sizeβ
Returns the decompressed size of a column in bytes.
Syntaxβ
-- Do not omit the brackets [] in the hint.
SELECT column_size(column_name) FROM table_name [_META_];
Parametersβ
column_name
: The name of the column for which you want to get the decompressed size.
Return valueβ
Returns the decompressed size of the column in bytes as a BIGINT value.
column_compressed_sizeβ
Returns the compressed size of a column in bytes.
Syntaxβ
-- Do not omit the brackets [] in the hint.
SELECT column_compressed_size(column_name) FROM table_name [_META_];
Parametersβ
column_name
: The name of the column for which you want to get the compressed size.
Return valueβ
Returns the compressed size of the column in bytes as a BIGINT value.
Usage notesβ
- Both functions must be used with the
[_META_]
hint to access metadata information. - The functions scan the metadata of underlying segment files using the META_SCAN operator.
- For complex data types (JSON, ARRAY, MAP, STRUCT), the functions recursively calculate the size of all sub-columns.
column_size
returns the uncompressed column size.column_compressed_size
returns the compressed on-disk size.
Examplesβ
-- Get both decompressed and compressed sizes of columns
SELECT
column_size(name) as name_decompressed_size,
column_compressed_size(name) as name_compressed_size,
column_size(description) as desc_decompressed_size,
column_compressed_size(description) as desc_compressed_size
FROM products [_META_];