This commit is contained in:
jsc0218 2024-09-03 02:38:48 +00:00
parent 1ba1efe3a7
commit 57996cc684
3 changed files with 8 additions and 7 deletions

View File

@ -164,8 +164,8 @@ ChunkAndProgress MergeTreeSelectProcessor::read()
}
auto chunk = Chunk(ordered_columns, res.row_count);
if (add_part_level)
chunk.getChunkInfos().add(std::make_shared<MergeTreeReadInfo>(task->getInfo().data_part->info.level, true));
chunk.getChunkInfos().add(std::make_shared<MergeTreeReadInfo>(
add_part_level ? task->getInfo().data_part->info.level : 0, true));
return ChunkAndProgress{
.chunk = std::move(chunk),
@ -190,7 +190,7 @@ ChunkAndProgress MergeTreeSelectProcessor::read()
auto chunk = Chunk(ordered_columns, res.row_count);
if (add_part_level)
chunk.getChunkInfos().add(std::make_shared<MergeTreeReadInfo>(task->getInfo().data_part->info.level, true));
chunk.getChunkInfos().add(std::make_shared<MergeTreeReadInfo>(task->getInfo().data_part->info.level, false));
return ChunkAndProgress{
.chunk = std::move(chunk),

View File

@ -195,14 +195,14 @@ INSERT INTO tab VALUES (201, 'rick c01'), (202, 'mick c02'), (203, 'nick c03');
SELECT name, type FROM system.data_skipping_indices WHERE table == 'tab' AND database = currentDatabase() LIMIT 1;
-- search full_text index
SELECT * FROM tab WHERE s LIKE '%01%' ORDER BY k SETTINGS optimize_read_in_order = 1;
SELECT * FROM tab WHERE s LIKE '%01%' ORDER BY k SETTINGS optimize_read_in_order = 0;
-- check the query only read 3 granules (6 rows total; each granule has 2 rows; there are 2 extra virtual rows)
-- check the query only read 3 granules (6 rows total; each granule has 2 rows)
SYSTEM FLUSH LOGS;
SELECT read_rows==8 from system.query_log
SELECT read_rows==6 from system.query_log
WHERE query_kind ='Select'
AND current_database = currentDatabase()
AND endsWith(trimRight(query), 'SELECT * FROM tab WHERE s LIKE \'%01%\' ORDER BY k SETTINGS optimize_read_in_order = 1;')
AND endsWith(trimRight(query), 'SELECT * FROM tab WHERE s LIKE \'%01%\' ORDER BY k SETTINGS optimize_read_in_order = 0;')
AND type='QueryFinish'
AND result_rows==3
LIMIT 1;

View File

@ -108,6 +108,7 @@ ORDER BY x ASC
LIMIT 4
SETTINGS max_block_size = 8192,
read_in_order_two_level_merge_threshold = 5, --avoid preliminary merge
read_in_order_use_buffering = false, --avoid buffer
max_threads = 1,
optimize_read_in_order = 1,
log_comment = 'no preliminary merge, with filter';