diff --git a/dbms/src/Common/ProfileEvents.cpp b/dbms/src/Common/ProfileEvents.cpp index 89e15f73f54..586aa158bdf 100644 --- a/dbms/src/Common/ProfileEvents.cpp +++ b/dbms/src/Common/ProfileEvents.cpp @@ -114,7 +114,7 @@ M(SelectedRanges, "Number of (non-adjacent) ranges in all data parts selected to read from a MergeTree table.") \ M(SelectedMarks, "Number of marks (index granules) selected to read from a MergeTree table.") \ \ - M(CountOfMerges, "") \ + M(Merge, "Number of launches background merges.") \ M(MergedRows, "Rows read for background merges. This is the number of rows before merge.") \ M(MergedUncompressedBytes, "Uncompressed bytes (for columns as they stored in memory) that was read for background merges. This is the number before merge.") \ M(MergesTimeMilliseconds, "Total time spent for background merges.")\ diff --git a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp index abdcd2d0f98..df3720359d3 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp @@ -39,7 +39,7 @@ namespace ProfileEvents extern const Event MergedRows; extern const Event MergedUncompressedBytes; extern const Event MergesTimeMilliseconds; - extern const Event CountOfMerges; + extern const Event Merge; } namespace CurrentMetrics @@ -511,7 +511,7 @@ public: if (stage.is_first) { ProfileEvents::increment(ProfileEvents::MergedRows, value.read_rows); - ProfileEvents::increment(ProfileEvents::CountOfMerges); + ProfileEvents::increment(ProfileEvents::Merge); } updateWatch(); diff --git a/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.reference b/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.reference new file mode 100644 index 00000000000..d00491fd7e5 --- /dev/null +++ b/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.reference @@ -0,0 +1 @@ +1 diff --git a/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.sql b/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.sql new file mode 100644 index 00000000000..609722fcf7f --- /dev/null +++ b/dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTs new_table_test; +DROP TABLE IF EXISTS check_table_test; + +CREATE TABLE IF NOT EXISTS new_table_test(name String) ENGINE = MergeTree Order By name; +CREATE TABLE IF NOT EXISTS check_table_test(value1 UInt64, value2 UInt64) ENGINE = MergeTree Order By tuple(); +INSERT INTO check_table_test (value1) SELECT value from system.events WHERE event = 'Merge'; +OPTIMIZE TABLE new_table_test FINAL; +INSERT INTO check_table_test (value2) SELECT value from system.events WHERE event = 'Merge'; +SELECT count() FROM check_table_test WHERE value2 > value1; + + +DROP TABLE new_table_test; +DROP TABLE check_table_test;