diff --git a/docs/en/operations/system-tables/processors_profile_log.md b/docs/en/operations/system-tables/processors_profile_log.md index 2a85dae6c44..2d76edb5dd7 100644 --- a/docs/en/operations/system-tables/processors_profile_log.md +++ b/docs/en/operations/system-tables/processors_profile_log.md @@ -6,6 +6,8 @@ Columns: - `event_date` ([Date](../../sql-reference/data-types/date.md)) — The date when the event happened. - `event_time` ([DateTime64](../../sql-reference/data-types/datetime64.md)) — The date and time when the event happened. +- `id` ([UInt64](../../sql-reference/data-types/int-uint.md)) — ID of processor +- `parent_ids` ([Array(UInt64)](../../sql-reference/data-types/array.md)) — Parent processors IDs - `query_id` ([String](../../sql-reference/data-types/string.md)) — ID of the query - `name` ([LowCardinality(String)](../../sql-reference/data-types/lowcardinality.md)) — Name of the processor. - `elapsed_us` ([UInt64](../../sql-reference/data-types/int-uint.md)) — Number of microseconds this processor was executed. diff --git a/src/Interpreters/ProcessorsProfileLog.cpp b/src/Interpreters/ProcessorsProfileLog.cpp index 8fda9826b5e..cd521876f09 100644 --- a/src/Interpreters/ProcessorsProfileLog.cpp +++ b/src/Interpreters/ProcessorsProfileLog.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -23,6 +24,9 @@ NamesAndTypesList ProcessorProfileLogElement::getNamesAndTypes() {"event_time", std::make_shared()}, {"event_time_microseconds", std::make_shared(6)}, + {"id", std::make_shared()}, + {"parent_ids", std::make_shared(std::make_shared())}, + {"query_id", std::make_shared()}, {"name", std::make_shared(std::make_shared())}, {"elapsed_us", std::make_shared()}, @@ -39,6 +43,15 @@ void ProcessorProfileLogElement::appendToBlock(MutableColumns & columns) const columns[i++]->insert(event_time); columns[i++]->insert(event_time_microseconds); + columns[i++]->insert(id); + { + Array parent_ids_array; + parent_ids_array.reserve(parent_ids.size()); + for (const UInt64 parent : parent_ids) + parent_ids_array.emplace_back(parent); + columns[i++]->insert(parent_ids_array); + } + columns[i++]->insertData(query_id.data(), query_id.size()); columns[i++]->insertData(processor_name.data(), processor_name.size()); columns[i++]->insert(elapsed_us); diff --git a/src/Interpreters/ProcessorsProfileLog.h b/src/Interpreters/ProcessorsProfileLog.h index eba5be1f167..d79ab6e5e5b 100644 --- a/src/Interpreters/ProcessorsProfileLog.h +++ b/src/Interpreters/ProcessorsProfileLog.h @@ -13,8 +13,12 @@ struct ProcessorProfileLogElement time_t event_time{}; Decimal64 event_time_microseconds{}; + UInt64 id; + std::vector parent_ids; + String query_id; String processor_name; + /// Milliseconds spend in IProcessor::work() UInt32 elapsed_us{}; /// IProcessor::NeedData diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 308d34adc90..a3349f12f8f 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -877,12 +877,31 @@ static std::tuple executeQueryImpl( processor_elem.event_time_microseconds = time_in_microseconds(finish_time); processor_elem.query_id = elem.client_info.current_query_id; + auto get_proc_id = [](const IProcessor & proc) -> UInt64 + { + return reinterpret_cast(&proc); + }; + for (const auto & processor : query_pipeline.getProcessors()) { + std::vector parents; + for (const auto & port : processor->getOutputs()) + { + if (!port.isConnected()) + continue; + const IProcessor & next = port.getInputPort().getProcessor(); + parents.push_back(get_proc_id(next)); + } + + processor_elem.id = get_proc_id(*processor); + processor_elem.parent_ids = std::move(parents); + processor_elem.processor_name = processor->getName(); + processor_elem.elapsed_us = processor->getElapsedUs(); processor_elem.input_wait_elapsed_us = processor->getInputWaitElapsedUs(); processor_elem.output_wait_elapsed_us = processor->getOutputWaitElapsedUs(); + processors_profile_log->add(processor_elem); } }