Merge pull request #34067 from Algunenano/mv_fixes

Fix  `parallel_view_processing=0` and `view_duration_ms` in views log
This commit is contained in:
alexey-milovidov 2022-02-12 22:36:41 +03:00 committed by GitHub
commit 4a2c69c073
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 73 additions and 2 deletions

View File

@ -331,7 +331,7 @@ Chain buildPushingToViewsChain(
{
auto executing_inner_query = std::make_shared<ExecutingInnerQueryFromViewTransform>(
storage_header, views_data->views.back(), views_data);
executing_inner_query->setRuntimeData(view_thread_status, elapsed_counter_ms);
executing_inner_query->setRuntimeData(view_thread_status, view_counter_ms);
out.addSource(std::move(executing_inner_query));
}
@ -381,7 +381,7 @@ Chain buildPushingToViewsChain(
processors.emplace_front(std::move(copying_data));
processors.emplace_back(std::move(finalizing_views));
result_chain = Chain(std::move(processors));
result_chain.setNumThreads(max_parallel_streams);
result_chain.setNumThreads(std::min(views_data->max_threads, max_parallel_streams));
}
if (auto * live_view = dynamic_cast<StorageLiveView *>(storage.get()))

View File

@ -0,0 +1,12 @@
VALUES 1
TABLE 1
VALUES 1
VALUES 1
VALUES 1
VALUES 1
VALUES 1
TABLE 1
TABLE 1
TABLE 1
TABLE 1
TABLE 1

View File

@ -0,0 +1,59 @@
CREATE TABLE IF NOT EXISTS a (a Int64) ENGINE=Memory;
CREATE TABLE IF NOT EXISTS b (a Int64) ENGINE=Memory;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv1 TO b AS Select sleepEachRow(0.05) as a FROM a;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv2 TO b AS Select sleepEachRow(0.05) as a FROM a;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv3 TO b AS Select sleepEachRow(0.05) as a FROM a;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv4 TO b AS Select sleepEachRow(0.05) as a FROM a;
CREATE MATERIALIZED VIEW IF NOT EXISTS mv5 TO b AS Select sleepEachRow(0.05) as a FROM a;
-- INSERT USING VALUES
INSERT INTO a VALUES (1);
-- INSERT USING TABLE
INSERT INTO a SELECT * FROM system.one;
SYSTEM FLUSH LOGS;
SELECT 'VALUES', query_duration_ms >= 250
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
AND type = 'QueryFinish'
LIMIT 1;
SELECT 'TABLE', query_duration_ms >= 250
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
AND type = 'QueryFinish'
LIMIT 1;
WITH
(
SELECT initial_query_id
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING VALUES%'
LIMIT 1
) AS q_id
SELECT 'VALUES', view_duration_ms >= 50
FROM system.query_views_log
WHERE initial_query_id = q_id;
WITH
(
SELECT initial_query_id
FROM system.query_log
WHERE
current_database = currentDatabase()
AND event_date >= yesterday()
AND query LIKE '-- INSERT USING TABLE%'
LIMIT 1
) AS q_id
SELECT 'TABLE', view_duration_ms >= 50
FROM system.query_views_log
WHERE initial_query_id = q_id;