#pragma once #include #include #include #include #include #include #include #include namespace ProfileEvents { class Counters; } namespace DB { /** Allows to log information about queries execution: * - info about start of query execution; * - performance metrics (are set at the end of query execution); * - info about errors of query execution. */ /// A struct which will be inserted as row into query_log table struct QueryLogElement { using Type = QueryLogElementType; Type type = QUERY_START; /// Depending on the type of query and type of stage, not all the fields may be filled. time_t event_time{}; Decimal64 event_time_microseconds{}; time_t query_start_time{}; Decimal64 query_start_time_microseconds{}; UInt64 query_duration_ms{}; /// The data fetched from DB to execute the query UInt64 read_rows{}; UInt64 read_bytes{}; /// The data written to DB UInt64 written_rows{}; UInt64 written_bytes{}; /// The data sent to the client UInt64 result_rows{}; UInt64 result_bytes{}; UInt64 memory_usage{}; String current_database; String query; String formatted_query; UInt64 normalized_query_hash{}; IAST::QueryKind query_kind{}; std::set query_databases; std::set query_tables; std::set query_columns; std::set query_projections; std::set query_views; std::unordered_set used_aggregate_functions; std::unordered_set used_aggregate_function_combinators; std::unordered_set used_database_engines; std::unordered_set used_data_type_families; std::unordered_set used_dictionaries; std::unordered_set used_formats; std::unordered_set used_functions; std::unordered_set used_storages; std::unordered_set used_table_functions; std::set used_row_policies; Int32 exception_code{}; // because ErrorCodes are int String exception; String stack_trace; std::string_view exception_format_string{}; ClientInfo client_info; String log_comment; std::vector thread_ids; std::shared_ptr profile_counters; std::shared_ptr async_read_counters; std::shared_ptr query_settings; TransactionID tid; static std::string name() { return "QueryLog"; } static NamesAndTypesList getNamesAndTypes(); static NamesAndAliases getNamesAndAliases(); void appendToBlock(MutableColumns & columns) const; static const char * getCustomColumnList() { return nullptr; } static void appendClientInfo(const ClientInfo & client_info, MutableColumns & columns, size_t & i); }; /// Instead of typedef - to allow forward declaration. class QueryLog : public SystemLog { using SystemLog::SystemLog; }; }