From a09c53233b5f9bb97104681a62b2d7021ea6a63a Mon Sep 17 00:00:00 2001 From: Duc Canh Le Date: Tue, 3 Oct 2023 01:27:45 +0000 Subject: [PATCH] only rebuild indexes when index granularity changes Signed-off-by: Duc Canh Le --- src/Interpreters/MutationsInterpreter.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Interpreters/MutationsInterpreter.cpp b/src/Interpreters/MutationsInterpreter.cpp index 4650ba39770..75ca951a22f 100644 --- a/src/Interpreters/MutationsInterpreter.cpp +++ b/src/Interpreters/MutationsInterpreter.cpp @@ -568,7 +568,8 @@ void MutationsInterpreter::prepare(bool dry_run) if (settings.recalculate_dependencies_of_updated_columns) dependencies = getAllColumnDependencies(metadata_snapshot, updated_columns, has_dependency); - bool need_rebuild_indexes_projections = false; + bool need_rebuild_indexes = false; + bool need_rebuild_projections = false; std::vector read_columns; /// First, break a sequence of commands into stages. @@ -589,7 +590,8 @@ void MutationsInterpreter::prepare(bool dry_run) predicate = makeASTFunction("isZeroOrNull", predicate); stages.back().filters.push_back(predicate); - need_rebuild_indexes_projections = true; + need_rebuild_indexes = true; + need_rebuild_projections = true; } else if (command.type == MutationCommand::UPDATE) { @@ -695,7 +697,7 @@ void MutationsInterpreter::prepare(bool dry_run) } if (source.isCompactPart() && source.getMergeTreeData() && source.getMergeTreeData()->getSettings()->index_granularity_bytes > 0) - need_rebuild_indexes_projections = true; + need_rebuild_indexes = true; } else if (command.type == MutationCommand::MATERIALIZE_COLUMN) { @@ -901,7 +903,7 @@ void MutationsInterpreter::prepare(bool dry_run) if (!source.hasSecondaryIndex(index.name)) continue; - if (need_rebuild_indexes_projections) + if (need_rebuild_indexes) { materialized_indices.insert(index.name); continue; @@ -922,7 +924,7 @@ void MutationsInterpreter::prepare(bool dry_run) if (!source.hasProjection(projection.name)) continue; - if (need_rebuild_indexes_projections) + if (need_rebuild_projections) { materialized_projections.insert(projection.name); continue;