Backport #70452 to 24.8: Don't prefetch parts with no rows

This commit is contained in:
robot-clickhouse 2024-10-08 14:09:31 +00:00
parent 1d81ea9619
commit c6112f052e
3 changed files with 16 additions and 1 deletions

View File

@ -174,7 +174,7 @@ MergeTreeSequentialSource::MergeTreeSequentialSource(
/*avg_value_size_hints=*/ {},
/*profile_callback=*/ {});
if (prefetch)
if (prefetch && !data_part->isEmpty())
reader->prefetchBeginOfRange(Priority{});
}

View File

@ -0,0 +1,15 @@
-- Tags: no-fasttest
DROP TABLE IF EXISTS 03250_avoid_prefetch;
CREATE table 03250_avoid_prefetch(id UInt64, string LowCardinality(String))
ENGINE = MergeTree
ORDER BY id
SETTINGS enable_vertical_merge_algorithm = 1, vertical_merge_algorithm_min_rows_to_activate = 1, vertical_merge_remote_filesystem_prefetch = 1,
vertical_merge_algorithm_min_bytes_to_activate = 1, vertical_merge_algorithm_min_columns_to_activate = 1,
min_rows_for_wide_part = 1, min_bytes_for_wide_part = 1, remove_empty_parts = 0, storage_policy = 's3_no_cache';
INSERT INTO 03250_avoid_prefetch VALUES (1, 'test');
ALTER TABLE 03250_avoid_prefetch DELETE WHERE id = 1;
INSERT INTO 03250_avoid_prefetch VALUES (2, 'test');
OPTIMIZE TABLE 03250_avoid_prefetch FINAL;