Merge pull request #6019 from yandex/fix-max-rows-to-read-without-uniform-read-distribution

Fixed error with calculating of max_rows_to_read if the setting merge_tree_uniform_read_distribution is set to zero.
This commit is contained in:
alexey-milovidov 2019-07-16 02:06:17 +03:00 committed by GitHub
commit b4306c13cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -46,13 +46,13 @@ MergeTreeSelectBlockInputStream::MergeTreeSelectBlockInputStream(
for (const auto & range : all_mark_ranges)
total_marks_count += range.end - range.begin;
size_t total_rows = data_part->index_granularity.getTotalRows();
size_t total_rows = data_part->index_granularity.getRowsCountInRanges(all_mark_ranges);
if (!quiet)
LOG_TRACE(log, "Reading " << all_mark_ranges.size() << " ranges from part " << data_part->name
<< ", approx. " << total_rows
<< (all_mark_ranges.size() > 1
? ", up to " + toString(data_part->index_granularity.getRowsCountInRanges(all_mark_ranges))
? ", up to " + toString(total_rows)
: "")
<< " rows starting from " << data_part->index_granularity.getMarkStartingRow(all_mark_ranges.front().begin));

View File

@ -0,0 +1,22 @@
DROP TABLE IF EXISTS merge_tree;
CREATE TABLE merge_tree (x UInt8) ENGINE = MergeTree ORDER BY x;
INSERT INTO merge_tree SELECT 0 FROM numbers(1000000);
SET max_threads = 4;
SET max_rows_to_read = 1100000;
SET merge_tree_uniform_read_distribution = 1;
SELECT count() FROM merge_tree;
SET merge_tree_uniform_read_distribution = 0;
SELECT count() FROM merge_tree;
SET max_rows_to_read = 900000;
SET merge_tree_uniform_read_distribution = 1;
SELECT count() FROM merge_tree; -- { serverError 158 }
SET merge_tree_uniform_read_distribution = 0;
SELECT count() FROM merge_tree; -- { serverError 158 }
DROP TABLE merge_tree;