slightly optimize very short queries with LowCardinality

This commit is contained in:
Anton Popov 2020-08-26 21:46:18 +03:00
parent 93d49e5815
commit eeb78bf291

View File

@ -43,11 +43,13 @@ MergeTreeReaderStream::MergeTreeReaderStream(
/// If the end of range is inside the block, we will need to read it too.
if (right_mark < marks_count && marks_loader.getMark(right_mark).offset_in_decompressed_block > 0)
{
while (right_mark < marks_count
&& marks_loader.getMark(right_mark).offset_in_compressed_file == marks_loader.getMark(mark_range.end).offset_in_compressed_file)
auto indices = ext::range(right_mark, marks_count);
auto it = std::upper_bound(indices.begin(), indices.end(), right_mark, [this](size_t i, size_t j)
{
++right_mark;
}
return marks_loader.getMark(i).offset_in_compressed_file < marks_loader.getMark(j).offset_in_compressed_file;
});
right_mark = (it == indices.end() ? marks_count : *it);
}
size_t mark_range_bytes;