2018-05-31 15:54:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/SystemLog.h>
|
2020-05-20 20:16:32 +00:00
|
|
|
#include <Interpreters/ClientInfo.h>
|
2022-01-10 19:01:41 +00:00
|
|
|
#include <Core/NamesAndTypes.h>
|
|
|
|
#include <Core/NamesAndAliases.h>
|
2018-05-31 15:54:08 +00:00
|
|
|
|
|
|
|
|
2018-06-14 13:03:23 +00:00
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
|
|
|
class Counters;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-31 15:54:08 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
struct QueryThreadLogElement
|
|
|
|
{
|
|
|
|
time_t event_time{};
|
2020-11-03 13:59:17 +00:00
|
|
|
Decimal64 event_time_microseconds{};
|
2018-05-31 15:54:08 +00:00
|
|
|
/// When query was attached to current thread
|
|
|
|
time_t query_start_time{};
|
2020-08-18 21:41:01 +00:00
|
|
|
/// same as above but adds microsecond precision
|
2020-11-03 13:59:17 +00:00
|
|
|
Decimal64 query_start_time_microseconds{};
|
2018-05-31 15:54:08 +00:00
|
|
|
/// Real time spent by the thread to execute the query
|
|
|
|
UInt64 query_duration_ms{};
|
|
|
|
|
|
|
|
/// The data fetched from DB in current thread to execute the query
|
|
|
|
UInt64 read_rows{};
|
|
|
|
UInt64 read_bytes{};
|
|
|
|
|
|
|
|
/// The data written to DB
|
|
|
|
UInt64 written_rows{};
|
|
|
|
UInt64 written_bytes{};
|
|
|
|
|
2018-06-09 15:29:08 +00:00
|
|
|
Int64 memory_usage{};
|
2018-06-20 15:21:42 +00:00
|
|
|
Int64 peak_memory_usage{};
|
2018-05-31 15:54:08 +00:00
|
|
|
|
2018-06-01 11:58:17 +00:00
|
|
|
String thread_name;
|
2020-02-02 20:01:13 +00:00
|
|
|
UInt64 thread_id{};
|
|
|
|
UInt64 master_thread_id{};
|
2018-05-31 15:54:08 +00:00
|
|
|
|
2020-10-30 18:16:10 +00:00
|
|
|
String current_database;
|
2018-05-31 15:54:08 +00:00
|
|
|
String query;
|
2020-12-15 19:29:25 +00:00
|
|
|
UInt64 normalized_query_hash{};
|
2020-10-30 18:16:10 +00:00
|
|
|
|
2018-05-31 15:54:08 +00:00
|
|
|
ClientInfo client_info;
|
|
|
|
|
2021-10-11 15:56:23 +00:00
|
|
|
std::shared_ptr<ProfileEvents::Counters::Snapshot> profile_counters;
|
2018-05-31 15:54:08 +00:00
|
|
|
|
|
|
|
static std::string name() { return "QueryThreadLog"; }
|
|
|
|
|
2021-06-28 11:42:21 +00:00
|
|
|
static NamesAndTypesList getNamesAndTypes();
|
|
|
|
static NamesAndAliases getNamesAndAliases();
|
2020-05-21 20:15:18 +00:00
|
|
|
void appendToBlock(MutableColumns & columns) const;
|
2018-05-31 15:54:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class QueryThreadLog : public SystemLog<QueryThreadLogElement>
|
|
|
|
{
|
|
|
|
using SystemLog<QueryThreadLogElement>::SystemLog;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|