Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add merge metric #7093

Merged
merged 5 commits into from Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions dbms/src/Common/ProfileEvents.cpp
Expand Up @@ -114,6 +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(Merge, "Number of launched 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.")\
Expand Down
4 changes: 4 additions & 0 deletions dbms/src/Storages/MergeTree/MergeTreeDataMergerMutator.cpp
Expand Up @@ -39,6 +39,7 @@ namespace ProfileEvents
extern const Event MergedRows;
extern const Event MergedUncompressedBytes;
extern const Event MergesTimeMilliseconds;
extern const Event Merge;
}

namespace CurrentMetrics
Expand Down Expand Up @@ -508,7 +509,10 @@ class MergeProgressCallback
{
ProfileEvents::increment(ProfileEvents::MergedUncompressedBytes, value.read_bytes);
if (stage.is_first)
{
ProfileEvents::increment(ProfileEvents::MergedRows, value.read_rows);
ProfileEvents::increment(ProfileEvents::Merge);
}
updateWatch();

merge_entry->bytes_read_uncompressed += value.read_bytes;
Expand Down
@@ -0,0 +1 @@
1
14 changes: 14 additions & 0 deletions dbms/tests/queries/0_stateless/01014_count_of_merges_metrics.sql
@@ -0,0 +1,14 @@
DROP TABLE IF EXISTS new_table_test;
DROP TABLE IF EXISTS check_table_test;

CREATE TABLE new_table_test(name String) ENGINE = MergeTree ORDER BY name;
INSERT INTO new_table_test VALUES ('test');
CREATE TABLE 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;