diff --git a/src/Storages/MergeTree/MergeTreeData.cpp b/src/Storages/MergeTree/MergeTreeData.cpp index 0fd73ab95ba..bc6e24c7c29 100644 --- a/src/Storages/MergeTree/MergeTreeData.cpp +++ b/src/Storages/MergeTree/MergeTreeData.cpp @@ -1280,11 +1280,19 @@ void MergeTreeData::dropAllData() LOG_TRACE(log, "dropAllData: removing data from memory."); DataPartsVector all_parts(data_parts_by_info.begin(), data_parts_by_info.end()); - DataPartsVector committed_parts = getDataPartsVector({DataPartState::Committed}); + + size_t committed_parts_count = 0; + for (const auto & parts_info : all_parts) + { + if (parts_info->state == DataPartState::Committed) + { + committed_parts_count++; + } + } CurrentMetrics::sub(CurrentMetrics::Parts, all_parts.size()); - CurrentMetrics::sub(CurrentMetrics::PartsActive, committed_parts.size()); - CurrentMetrics::sub(CurrentMetrics::PartsInactive, all_parts.size() - committed_parts.size()); + CurrentMetrics::sub(CurrentMetrics::PartsActive, committed_parts_count); + CurrentMetrics::sub(CurrentMetrics::PartsInactive, all_parts.size() - committed_parts_count); data_parts_indexes.clear(); column_sizes.clear();