only rebuild indexes when index granularity changes

Signed-off-by: Duc Canh Le <duccanh.le@ahrefs.com>
This commit is contained in:
Duc Canh Le 2023-10-03 01:27:45 +00:00
parent 57e902d375
commit a09c53233b

View File

@ -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<String> 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;