Add SelectedRows and SelectedBytes events

This commit is contained in:
Anton Ivashkin 2020-07-21 17:50:02 +03:00
parent 1d0be5495c
commit 742793be54
5 changed files with 54 additions and 0 deletions

View File

@ -117,6 +117,8 @@
M(SelectedParts, "Number of data parts selected to read from a MergeTree table.") \
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(SelectedRows, "Number of rows SELECTed from all tables.") \
M(SelectedBytes, "Number of bytes (uncompressed; for columns as they stored in memory) SELECTed from all tables.") \
\
M(Merge, "Number of launched background merges.") \
M(MergedRows, "Rows read for background merges. This is the number of rows before merge.") \

View File

@ -9,6 +9,8 @@
namespace ProfileEvents
{
extern const Event ThrottlerSleepMicroseconds;
extern const Event SelectedRows;
extern const Event SelectedBytes;
}
@ -268,6 +270,9 @@ void IBlockInputStream::progressImpl(const Progress & value)
if (quota && limits.mode == LIMITS_TOTAL)
quota->used({Quota::READ_ROWS, value.read_rows}, {Quota::READ_BYTES, value.read_bytes});
}
ProfileEvents::increment(ProfileEvents::SelectedRows, value.read_rows);
ProfileEvents::increment(ProfileEvents::SelectedBytes, value.read_bytes);
}

View File

@ -3,6 +3,12 @@
#include <Interpreters/ProcessList.h>
#include <Access/EnabledQuota.h>
namespace ProfileEvents
{
extern const Event SelectedRows;
extern const Event SelectedBytes;
}
namespace DB
{
@ -107,6 +113,9 @@ void SourceWithProgress::progress(const Progress & value)
if (quota && limits.mode == LimitsMode::LIMITS_TOTAL)
quota->used({Quota::READ_ROWS, value.read_rows}, {Quota::READ_BYTES, value.read_bytes});
}
ProfileEvents::increment(ProfileEvents::SelectedRows, value.read_rows);
ProfileEvents::increment(ProfileEvents::SelectedBytes, value.read_bytes);
}
}

View File

@ -0,0 +1,7 @@
1
1
2
2
2 2
3
3

View File

@ -0,0 +1,31 @@
DROP TABLE IF EXISTS rows_events_test;
CREATE TABLE rows_events_test (k UInt32, v UInt32) ENGINE = MergeTree ORDER BY k;
SYSTEM FLUSH LOGS;
TRUNCATE TABLE system.query_log;
INSERT INTO rows_events_test VALUES (1,1);
SYSTEM FLUSH LOGS;
SELECT written_rows FROM system.query_log WHERE query LIKE 'INSERT INTO rows_events_test%' AND type=2;
SELECT value FROM (
SELECT ProfileEvents.Names as name, ProfileEvents.Values as value FROM system.query_log ARRAY JOIN ProfileEvents WHERE query LIKE 'INSERT INTO rows_events_test%' AND type=2
) WHERE name='InsertedRows';
SYSTEM FLUSH LOGS;
TRUNCATE TABLE system.query_log;
INSERT INTO rows_events_test VALUES (2,2), (3,3);
SYSTEM FLUSH LOGS;
SELECT written_rows FROM system.query_log WHERE query LIKE 'INSERT INTO rows_events_test%' AND type=2;
SELECT value FROM (
SELECT ProfileEvents.Names as name, ProfileEvents.Values as value FROM system.query_log ARRAY JOIN ProfileEvents WHERE query LIKE 'INSERT INTO rows_events_test%' AND type=2
) WHERE name='InsertedRows';
SYSTEM FLUSH LOGS;
TRUNCATE TABLE system.query_log;
SELECT * FROM rows_events_test WHERE v = 2;
SYSTEM FLUSH LOGS;
SELECT read_rows FROM system.query_log WHERE query LIKE 'SELECT * FROM rows_events_test%' AND type=2;
SELECT value FROM (
SELECT ProfileEvents.Names as name, ProfileEvents.Values as value FROM system.query_log ARRAY JOIN ProfileEvents WHERE query LIKE 'SELECT * FROM rows_events_test%' AND type=2
) WHERE name='SelectedRows';
DROP TABLE rows_events_test;