mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #31825 from azat/query_views_log-test
Cover query_views_log
This commit is contained in:
commit
c7a8ad69c4
@ -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
|
||||
|
@ -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 (...)
|
||||
{
|
||||
|
24
tests/queries/0_stateless/02125_query_views_log.reference
Normal file
24
tests/queries/0_stateless/02125_query_views_log.reference
Normal 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
|
16
tests/queries/0_stateless/02125_query_views_log.sql
Normal file
16
tests/queries/0_stateless/02125_query_views_log.sql
Normal 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;
|
Loading…
Reference in New Issue
Block a user