Syntax
mergeTreeIndex(database, table [, with_marks = true] [, with_minmax = true])
Arguments
| Argument | Description |
|---|---|
database | The database name to read index and marks from. |
table | The table name to read index and marks from. |
with_marks | Whether include columns with marks to the result. |
with_minmax | Whether include min-max index to the result. |
Returned value
A table object with columns with values of primary index and min-max index (if enabled) of source table, columns with values of marks (if enabled) for all possible files in data parts of source table and virtual columns:part_name- The name of data part.mark_number- The number of current mark in data part.rows_in_granule- The number of rows in current granule.
(NULL, NULL) value in case when column is absent in data part or marks for one of its substreams are not written (e.g. in compact parts).
Usage Example
CREATE TABLE test_table
(
`id` UInt64,
`n` UInt64,
`arr` Array(UInt64)
)
ENGINE = MergeTree
ORDER BY id
SETTINGS index_granularity = 3, min_bytes_for_wide_part = 0, min_rows_for_wide_part = 8;
INSERT INTO test_table SELECT number, number, range(number % 5) FROM numbers(5);
INSERT INTO test_table SELECT number, number, range(number % 5) FROM numbers(10, 10);
SELECT * FROM mergeTreeIndex(currentDatabase(), test_table, with_marks = true);
ββpart_nameββ¬βmark_numberββ¬βrows_in_granuleββ¬βidββ¬βid.markββ¬βn.markβββ¬βarr.size0.markββ¬βarr.markββ
β all_1_1_0 β 0 β 3 β 0 β (0,0) β (42,0) β (NULL,NULL) β (84,0) β
β all_1_1_0 β 1 β 2 β 3 β (133,0) β (172,0) β (NULL,NULL) β (211,0) β
β all_1_1_0 β 2 β 0 β 4 β (271,0) β (271,0) β (NULL,NULL) β (271,0) β
βββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββ΄βββββ΄ββββββββββ΄ββββββββββ΄βββββββββββββββββ΄βββββββββββ
ββpart_nameββ¬βmark_numberββ¬βrows_in_granuleββ¬βidββ¬βid.markββ¬βn.markββ¬βarr.size0.markββ¬βarr.markββ
β all_2_2_0 β 0 β 3 β 10 β (0,0) β (0,0) β (0,0) β (0,0) β
β all_2_2_0 β 1 β 3 β 13 β (0,24) β (0,24) β (0,24) β (0,24) β
β all_2_2_0 β 2 β 3 β 16 β (0,48) β (0,48) β (0,48) β (0,80) β
β all_2_2_0 β 3 β 1 β 19 β (0,72) β (0,72) β (0,72) β (0,128) β
β all_2_2_0 β 4 β 0 β 19 β (0,80) β (0,80) β (0,80) β (0,160) β
βββββββββββββ΄ββββββββββββββ΄ββββββββββββββββββ΄βββββ΄ββββββββββ΄βββββββββ΄βββββββββββββββββ΄βββββββββββ
DESCRIBE mergeTreeIndex(currentDatabase(), test_table, with_marks = true) SETTINGS describe_compact_output = 1;
ββnameβββββββββββββ¬βtypeββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β part_name β String β
β mark_number β UInt64 β
β rows_in_granule β UInt64 β
β id β UInt64 β
β id.mark β Tuple(offset_in_compressed_file Nullable(UInt64), offset_in_decompressed_block Nullable(UInt64)) β
β n.mark β Tuple(offset_in_compressed_file Nullable(UInt64), offset_in_decompressed_block Nullable(UInt64)) β
β arr.size0.mark β Tuple(offset_in_compressed_file Nullable(UInt64), offset_in_decompressed_block Nullable(UInt64)) β
β arr.mark β Tuple(offset_in_compressed_file Nullable(UInt64), offset_in_decompressed_block Nullable(UInt64)) β
βββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ