mergeTreeIndex
mergeTreeIndex
MergeTree 테이블의 인덱스와 마크(mark) 파일의 내용을 나타내는 테이블 함수예요. 내부 구조를 들여다보는(introspection) 용도로 사용해요.
출처: 문서
본문
MergeTree 테이블의 인덱스와 마크(mark) 파일의 내용을 나타내요. 내부 구조를 들여다보는 데 사용할 수 있어요.
문법 (Syntax)
mergeTreeIndex(database, table [, with_marks = true] [, with_minmax = true])
인자 (Arguments)
| 인자 | 설명 |
|---|---|
database |
인덱스와 마크를 읽을 데이터베이스 이름이에요. |
table |
인덱스와 마크를 읽을 테이블 이름이에요. |
with_marks |
결과에 마크가 있는 컬럼을 포함할지 여부예요. |
with_minmax |
결과에 최소-최대(min-max) 인덱스를 포함할지 여부예요. |
반환값 (Returned value)
소스 테이블의 기본 인덱스 값과 (활성화된 경우) 최소-최대 인덱스 값, (활성화된 경우) 소스 테이블 데이터 파트의 모든 가능한 파일에 대한 마크 값, 그리고 가상 컬럼을 갖는 테이블 객체예요:
part_name- 데이터 파트의 이름이에요.mark_number- 데이터 파트 내 현재 마크 번호예요.rows_in_granule- 현재 그라뉼(granule)의 행 수예요.
컬럼이 데이터 파트에 없거나 그 서브스트림 중 하나에 대한 마크가 기록되지 않은 경우(예: compact 파트) 마크 컬럼은 (NULL, NULL) 값을 가질 수 있어요.
사용 예시 (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)) │
└─────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────┘