Merge pull request #31825 from azat/query_views_log-test

Cover query_views_log
This commit is contained in:
Kseniia Sumarokova 2021-11-29 16:10:56 +03:00 committed by GitHub
commit c7a8ad69c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 5 deletions

View File

@ -165,7 +165,7 @@ protected:
std::function<void()> fatal_error_callback;
/// It is used to avoid enabling the query profiler when you have multiple ThreadStatus in the same thread
bool query_profiled_enabled = true;
bool query_profiler_enabled = true;
/// Requires access to query_id.
friend class MemoryTrackerThreadSwitcher;
@ -207,7 +207,8 @@ public:
void disableProfiling()
{
query_profiled_enabled = false;
assert(!query_profiler_real && !query_profiler_cpu);
query_profiler_enabled = false;
}
/// Starts new query and create new thread group for it, current thread becomes master thread of the query

View File

@ -310,7 +310,7 @@ void ThreadStatus::resetPerformanceCountersLastUsage()
void ThreadStatus::initQueryProfiler()
{
if (!query_profiled_enabled)
if (!query_profiler_enabled)
return;
/// query profilers are useless without trace collector
@ -326,11 +326,11 @@ void ThreadStatus::initQueryProfiler()
{
if (settings.query_profiler_real_time_period_ns > 0)
query_profiler_real = std::make_unique<QueryProfilerReal>(thread_id,
/* period */ static_cast<UInt32>(settings.query_profiler_real_time_period_ns));
/* period= */ static_cast<UInt32>(settings.query_profiler_real_time_period_ns));
if (settings.query_profiler_cpu_time_period_ns > 0)
query_profiler_cpu = std::make_unique<QueryProfilerCPU>(thread_id,
/* period */ static_cast<UInt32>(settings.query_profiler_cpu_time_period_ns));
/* period= */ static_cast<UInt32>(settings.query_profiler_cpu_time_period_ns));
}
catch (...)
{

View File

@ -0,0 +1,24 @@
-- { echo }
select view_name, read_rows, read_bytes, written_rows, written_bytes from system.query_views_log where startsWith(view_name, currentDatabase() || '.mv') order by view_name format Vertical;
Row 1:
──────
view_name: default.mv1
read_rows: 1000000
read_bytes: 4000000
written_rows: 1000000
written_bytes: 4000000
Row 2:
──────
view_name: default.mv2
read_rows: 1000000
read_bytes: 4000000
written_rows: 1000000
written_bytes: 4000000
select read_rows, read_bytes, written_rows, written_bytes from system.query_log where type = 'QueryFinish' and query_kind = 'Insert' and current_database = currentDatabase() format Vertical;
Row 1:
──────
read_rows: 1000000
read_bytes: 8000000
written_rows: 3000000
written_bytes: 12000000

View File

@ -0,0 +1,16 @@
drop table if exists src;
drop table if exists dst;
drop table if exists mv1;
drop table if exists mv2;
create table src (key Int) engine=Null();
create table dst (key Int) engine=Null();
create materialized view mv1 to dst as select * from src;
create materialized view mv2 to dst as select * from src;
insert into src select * from numbers(1e6) settings log_queries=1, max_untracked_memory=0, parallel_view_processing=1;
system flush logs;
-- { echo }
select view_name, read_rows, read_bytes, written_rows, written_bytes from system.query_views_log where startsWith(view_name, currentDatabase() || '.mv') order by view_name format Vertical;
select read_rows, read_bytes, written_rows, written_bytes from system.query_log where type = 'QueryFinish' and query_kind = 'Insert' and current_database = currentDatabase() format Vertical;