MV: Test profile events and view type

This commit is contained in:
Raúl Marín 2021-08-10 11:31:39 +02:00
parent 315b611963
commit 770aa427f1
2 changed files with 91 additions and 17 deletions

View File

@ -1,6 +1,70 @@
{"stage":"Query log rows","read_rows":"100","written_rows":"201","databases":["_table_function","default"],"tables":["_table_function.numbers","default.table_a","default.table_b","default.table_b_live_view","default.table_c"],"views":["default.matview_a_to_b","default.matview_b_to_c","default.table_b_live_view"]}
{"stage":"Depending views","view_name":"default.matview_a_to_b","status":"QueryFinish","view_target":"default.table_b","view_query":"SELECT toFloat64(a) AS a, b AS count FROM default.table_a","read_rows":"100","written_rows":"100"}
{"stage":"Depending views","view_name":"default.matview_b_to_c","status":"QueryFinish","view_target":"default.table_c","view_query":"SELECT sum(a) AS a FROM default.table_b","read_rows":"100","written_rows":"1"}
{"stage":"Depending views","view_name":"default.table_b_live_view","status":"QueryFinish","view_target":"default.table_b_live_view","view_query":"SELECT sum(a + b) FROM default.table_b","read_rows":"100","written_rows":"0"}
{"stage":"Query log rows 2","read_rows":"50","written_rows":"100","databases":["_table_function","default"],"tables":["_table_function.numbers","default.table_d","default.table_e","default.table_f"],"views":["default.matview_join_d_e"]}
{"stage":"Depending views 2","view_name":"default.matview_join_d_e","status":"QueryFinish","view_target":"default.table_f","view_query":"SELECT table_d.a AS a, table_e.count AS count FROM default.table_d LEFT JOIN default.table_e ON table_d.a = table_e.a","read_rows":"50","written_rows":"50"}
Row 1:
──────
stage: Query log rows
read_rows: 100
written_rows: 201
databases: ['_table_function','default']
tables: ['_table_function.numbers','default.table_a','default.table_b','default.table_b_live_view','default.table_c']
views: ['default.matview_a_to_b','default.matview_b_to_c','default.table_b_live_view']
sleep_calls: 200
sleep_us: 298
Row 1:
──────
stage: Depending views
view_name: default.matview_a_to_b
view_type: Materialized
status: QueryFinish
view_target: default.table_b
view_query: SELECT toFloat64(a) AS a, b + sleepEachRow(0.000001) AS count FROM default.table_a
read_rows: 100
written_rows: 100
sleep_calls: 100
sleep_us: 99
Row 2:
──────
stage: Depending views
view_name: default.matview_b_to_c
view_type: Materialized
status: QueryFinish
view_target: default.table_c
view_query: SELECT sum(a + sleepEachRow(0.000002)) AS a FROM default.table_b
read_rows: 100
written_rows: 1
sleep_calls: 100
sleep_us: 199
Row 3:
──────
stage: Depending views
view_name: default.table_b_live_view
view_type: Live
status: QueryFinish
view_target: default.table_b_live_view
view_query: SELECT sum(a + b) FROM default.table_b
read_rows: 100
written_rows: 0
sleep_calls: 0
sleep_us: 0
Row 1:
──────
stage: Query log rows 2
read_rows: 50
written_rows: 100
databases: ['_table_function','default']
tables: ['_table_function.numbers','default.table_d','default.table_e','default.table_f']
views: ['default.matview_join_d_e']
sleep_calls: 50
sleep_us: 150
Row 1:
──────
stage: Depending views 2
view_name: default.matview_join_d_e
view_type: Materialized
status: QueryFinish
view_target: default.table_f
view_query: SELECT table_d.a AS a, table_e.count + sleepEachRow(0.000003) AS count FROM default.table_d LEFT JOIN default.table_e ON table_d.a = table_e.a
read_rows: 50
written_rows: 50
sleep_calls: 50
sleep_us: 150

View File

@ -12,9 +12,9 @@ CREATE TABLE table_e (a Float64, count Int64) ENGINE MergeTree ORDER BY a;
CREATE TABLE table_f (a Float64, count Int64) ENGINE MergeTree ORDER BY a;
-- SETUP MATERIALIZED VIEWS
CREATE MATERIALIZED VIEW matview_a_to_b TO table_b AS SELECT toFloat64(a) AS a, b AS count FROM table_a;
CREATE MATERIALIZED VIEW matview_b_to_c TO table_c AS SELECT SUM(a) as a FROM table_b;
CREATE MATERIALIZED VIEW matview_join_d_e TO table_f AS SELECT table_d.a as a, table_e.count as count FROM table_d LEFT JOIN table_e ON table_d.a = table_e.a;
CREATE MATERIALIZED VIEW matview_a_to_b TO table_b AS SELECT toFloat64(a) AS a, b + sleepEachRow(0.000001) AS count FROM table_a;
CREATE MATERIALIZED VIEW matview_b_to_c TO table_c AS SELECT SUM(a + sleepEachRow(0.000002)) as a FROM table_b;
CREATE MATERIALIZED VIEW matview_join_d_e TO table_f AS SELECT table_d.a as a, table_e.count + sleepEachRow(0.000003) as count FROM table_d LEFT JOIN table_e ON table_d.a = table_e.a;
-- SETUP LIVE VIEW
---- table_b_live_view (Int64)
@ -43,21 +43,26 @@ SELECT
written_rows,
arraySort(databases) as databases,
arraySort(tables) as tables,
arraySort(views) as views
arraySort(views) as views,
ProfileEvents['SleepFunctionCalls'] as sleep_calls,
ProfileEvents['SleepFunctionMicroseconds'] as sleep_us
FROM system.query_log
WHERE query like '-- INSERT 1%INSERT INTO table_a%'
AND current_database = currentDatabase()
AND event_date >= yesterday()
FORMAT JSONEachRow;
FORMAT Vertical;
SELECT
'Depending views' as stage,
view_name,
view_type,
status,
view_target,
view_query,
read_rows,
written_rows
written_rows,
ProfileEvents['SleepFunctionCalls'] as sleep_calls,
ProfileEvents['SleepFunctionMicroseconds'] as sleep_us
FROM system.query_views_log
WHERE initial_query_id =
(
@ -69,7 +74,7 @@ WHERE initial_query_id =
LIMIT 1
)
ORDER BY view_name
FORMAT JSONEachRow;
FORMAT Vertical;
-- CHECK LOGS OF INSERT 2
SELECT
@ -78,21 +83,26 @@ SELECT
written_rows,
arraySort(databases) as databases,
arraySort(tables) as tables,
arraySort(views) as views
arraySort(views) as views,
ProfileEvents['SleepFunctionCalls'] as sleep_calls,
ProfileEvents['SleepFunctionMicroseconds'] as sleep_us
FROM system.query_log
WHERE query like '-- INSERT 2%INSERT INTO table_d%'
AND current_database = currentDatabase()
AND event_date >= yesterday()
FORMAT JSONEachRow;
FORMAT Vertical;
SELECT
'Depending views 2' as stage,
view_name,
view_type,
status,
view_target,
view_query,
read_rows,
written_rows
written_rows,
ProfileEvents['SleepFunctionCalls'] as sleep_calls,
ProfileEvents['SleepFunctionMicroseconds'] as sleep_us
FROM system.query_views_log
WHERE initial_query_id =
(
@ -104,7 +114,7 @@ WHERE initial_query_id =
LIMIT 1
)
ORDER BY view_name
FORMAT JSONEachRow;
FORMAT Vertical;
-- TEARDOWN
DROP TABLE table_b_live_view;