mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 03:22:14 +00:00
Merge pull request #59405 from nickitat/dont_merge_just_created_aggr_projection_block
Don't merge just created aggregating projection blocks
This commit is contained in:
commit
77c5221a0e
@ -618,7 +618,8 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeTempPartImpl(
|
|||||||
|
|
||||||
if (projection_block.rows())
|
if (projection_block.rows())
|
||||||
{
|
{
|
||||||
auto proj_temp_part = writeProjectionPart(data, log, projection_block, projection, new_data_part.get());
|
auto proj_temp_part
|
||||||
|
= writeProjectionPart(data, log, projection_block, projection, new_data_part.get(), /*merge_is_needed=*/false);
|
||||||
new_data_part->addProjectionPart(projection.name, std::move(proj_temp_part.part));
|
new_data_part->addProjectionPart(projection.name, std::move(proj_temp_part.part));
|
||||||
for (auto & stream : proj_temp_part.streams)
|
for (auto & stream : proj_temp_part.streams)
|
||||||
temp_part.streams.emplace_back(std::move(stream));
|
temp_part.streams.emplace_back(std::move(stream));
|
||||||
@ -647,7 +648,8 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeProjectionPartImpl(
|
|||||||
const MergeTreeData & data,
|
const MergeTreeData & data,
|
||||||
LoggerPtr log,
|
LoggerPtr log,
|
||||||
Block block,
|
Block block,
|
||||||
const ProjectionDescription & projection)
|
const ProjectionDescription & projection,
|
||||||
|
bool merge_is_needed)
|
||||||
{
|
{
|
||||||
TemporaryPart temp_part;
|
TemporaryPart temp_part;
|
||||||
const auto & metadata_snapshot = projection.metadata;
|
const auto & metadata_snapshot = projection.metadata;
|
||||||
@ -716,7 +718,7 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeProjectionPartImpl(
|
|||||||
ProfileEvents::increment(ProfileEvents::MergeTreeDataProjectionWriterBlocksAlreadySorted);
|
ProfileEvents::increment(ProfileEvents::MergeTreeDataProjectionWriterBlocksAlreadySorted);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (projection.type == ProjectionDescription::Type::Aggregate)
|
if (projection.type == ProjectionDescription::Type::Aggregate && merge_is_needed)
|
||||||
{
|
{
|
||||||
ProfileEventTimeIncrement<Microseconds> watch(ProfileEvents::MergeTreeDataProjectionWriterMergingBlocksMicroseconds);
|
ProfileEventTimeIncrement<Microseconds> watch(ProfileEvents::MergeTreeDataProjectionWriterMergingBlocksMicroseconds);
|
||||||
|
|
||||||
@ -756,16 +758,11 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeProjectionPart(
|
|||||||
LoggerPtr log,
|
LoggerPtr log,
|
||||||
Block block,
|
Block block,
|
||||||
const ProjectionDescription & projection,
|
const ProjectionDescription & projection,
|
||||||
IMergeTreeDataPart * parent_part)
|
IMergeTreeDataPart * parent_part,
|
||||||
|
bool merge_is_needed)
|
||||||
{
|
{
|
||||||
return writeProjectionPartImpl(
|
return writeProjectionPartImpl(
|
||||||
projection.name,
|
projection.name, false /* is_temp */, parent_part, data, log, std::move(block), projection, merge_is_needed);
|
||||||
false /* is_temp */,
|
|
||||||
parent_part,
|
|
||||||
data,
|
|
||||||
log,
|
|
||||||
std::move(block),
|
|
||||||
projection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is used for projection materialization process which may contain multiple stages of
|
/// This is used for projection materialization process which may contain multiple stages of
|
||||||
@ -780,13 +777,7 @@ MergeTreeDataWriter::TemporaryPart MergeTreeDataWriter::writeTempProjectionPart(
|
|||||||
{
|
{
|
||||||
auto part_name = fmt::format("{}_{}", projection.name, block_num);
|
auto part_name = fmt::format("{}_{}", projection.name, block_num);
|
||||||
return writeProjectionPartImpl(
|
return writeProjectionPartImpl(
|
||||||
part_name,
|
part_name, true /* is_temp */, parent_part, data, log, std::move(block), projection, /*merge_is_needed=*/true);
|
||||||
true /* is_temp */,
|
|
||||||
parent_part,
|
|
||||||
data,
|
|
||||||
log,
|
|
||||||
std::move(block),
|
|
||||||
projection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,8 @@ public:
|
|||||||
LoggerPtr log,
|
LoggerPtr log,
|
||||||
Block block,
|
Block block,
|
||||||
const ProjectionDescription & projection,
|
const ProjectionDescription & projection,
|
||||||
IMergeTreeDataPart * parent_part);
|
IMergeTreeDataPart * parent_part,
|
||||||
|
bool merge_is_needed);
|
||||||
|
|
||||||
/// For mutation: MATERIALIZE PROJECTION.
|
/// For mutation: MATERIALIZE PROJECTION.
|
||||||
static TemporaryPart writeTempProjectionPart(
|
static TemporaryPart writeTempProjectionPart(
|
||||||
@ -129,7 +130,8 @@ private:
|
|||||||
const MergeTreeData & data,
|
const MergeTreeData & data,
|
||||||
LoggerPtr log,
|
LoggerPtr log,
|
||||||
Block block,
|
Block block,
|
||||||
const ProjectionDescription & projection);
|
const ProjectionDescription & projection,
|
||||||
|
bool merge_is_needed);
|
||||||
|
|
||||||
MergeTreeData & data;
|
MergeTreeData & data;
|
||||||
LoggerPtr log;
|
LoggerPtr log;
|
||||||
|
@ -36,7 +36,7 @@ FROM numbers_mt(1000000);
|
|||||||
$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS"
|
$CLICKHOUSE_CLIENT -q "SYSTEM FLUSH LOGS"
|
||||||
$CLICKHOUSE_CLIENT -q """
|
$CLICKHOUSE_CLIENT -q """
|
||||||
SELECT
|
SELECT
|
||||||
ProfileEvents['MergeTreeDataProjectionWriterMergingBlocksMicroseconds'] > 0,
|
ProfileEvents['MergeTreeDataProjectionWriterMergingBlocksMicroseconds'] = 0,
|
||||||
ProfileEvents['MergeTreeDataProjectionWriterSortingBlocksMicroseconds'] > 0,
|
ProfileEvents['MergeTreeDataProjectionWriterSortingBlocksMicroseconds'] > 0,
|
||||||
ProfileEvents['MergeTreeDataWriterSortingBlocksMicroseconds'] > 0,
|
ProfileEvents['MergeTreeDataWriterSortingBlocksMicroseconds'] > 0,
|
||||||
ProfileEvents['MergeTreeDataWriterProjectionsCalculationMicroseconds'] > 0,
|
ProfileEvents['MergeTreeDataWriterProjectionsCalculationMicroseconds'] > 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user