diff --git a/src/Interpreters/InterpreterExplainQuery.cpp b/src/Interpreters/InterpreterExplainQuery.cpp index 9084bae8973..5a43c949129 100644 --- a/src/Interpreters/InterpreterExplainQuery.cpp +++ b/src/Interpreters/InterpreterExplainQuery.cpp @@ -245,8 +245,7 @@ struct ExecutionAnalysisSettings constexpr static char name[] = "ANALYZE"; - std::unordered_map> boolean_settings = - { + std::unordered_map> boolean_settings = { {"graph", graph}, }; @@ -631,19 +630,20 @@ QueryPipeline InterpreterExplainQuery::executeImpl() break; } - case ASTExplainQuery::ExecutionAnalysis: - { - if(dynamic_cast(ast.getExplainedQuery().get())) { + case ASTExplainQuery::ExecutionAnalysis: { + if (dynamic_cast(ast.getExplainedQuery().get())) + { auto settings = checkAndGetSettings(ast.getSettings()); BlockIO res; //Build Query Plan - if(getContext()->getSettingsRef().allow_experimental_analyzer) + if (getContext()->getSettingsRef().allow_experimental_analyzer) { InterpreterSelectQueryAnalyzer interpreter(ast.getExplainedQuery(), getContext(), options); res = interpreter.execute(); } - else { + else + { InterpreterSelectWithUnionQuery interpreter(ast.getExplainedQuery(), getContext(), options); res = interpreter.execute(); } @@ -652,13 +652,15 @@ QueryPipeline InterpreterExplainQuery::executeImpl() const auto & processors = pipeline.getProcessors(); PullingPipelineExecutor pulling_executor(pipeline, true); - while(true) { + while (true) + { Block block; - if(!pulling_executor.pull(block)) + if (!pulling_executor.pull(block)) break; } - if(settings.graph) { + if (settings.graph) + { printExecutionAnalysis(processors, buf); } else diff --git a/src/Parsers/ParserExplainQuery.cpp b/src/Parsers/ParserExplainQuery.cpp index 219d014f9ba..07231d926ec 100644 --- a/src/Parsers/ParserExplainQuery.cpp +++ b/src/Parsers/ParserExplainQuery.cpp @@ -47,7 +47,7 @@ bool ParserExplainQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected kind = ASTExplainQuery::ExplainKind::TableOverride; else if (s_current_transaction.ignore(pos, expected)) kind = ASTExplainQuery::ExplainKind::CurrentTransaction; - else if(s_analyze.ignore(pos, expected)) + else if (s_analyze.ignore(pos, expected)) kind = ASTExplainQuery::ExplainKind::ExecutionAnalysis; } else diff --git a/src/Processors/Executors/PipelineExecutor.cpp b/src/Processors/Executors/PipelineExecutor.cpp index b9640efab5f..5382abbde41 100644 --- a/src/Processors/Executors/PipelineExecutor.cpp +++ b/src/Processors/Executors/PipelineExecutor.cpp @@ -71,7 +71,9 @@ PipelineExecutor::PipelineExecutor(std::shared_ptr & processors, Que } } -PipelineExecutor::PipelineExecutor(std::shared_ptr & processors, QueryStatusPtr elem, bool profile_processors_): PipelineExecutor(processors, elem) { +PipelineExecutor::PipelineExecutor(std::shared_ptr & processors, QueryStatusPtr elem, bool profile_processors_) + : PipelineExecutor(processors, elem) +{ profile_processors = profile_processors || profile_processors_; } diff --git a/src/QueryPipeline/printPipeline.cpp b/src/QueryPipeline/printPipeline.cpp index 496ce3c118c..c2f36aef548 100644 --- a/src/QueryPipeline/printPipeline.cpp +++ b/src/QueryPipeline/printPipeline.cpp @@ -174,7 +174,8 @@ void printPipelineCompact(const Processors & processors, WriteBuffer & out, bool out << "}\n"; } -void printExecutionAnalysis(const Processors & processors, WriteBuffer & out) { +void printExecutionAnalysis(const Processors & processors, WriteBuffer & out) +{ out << "digraph\n"; out << "{\n"; out << " rankdir=\"LR\";\n"; @@ -188,7 +189,8 @@ void printExecutionAnalysis(const Processors & processors, WriteBuffer & out) { }; - for(const auto & processor : processors) { + for (const auto & processor : processors) + { const auto & description = processor->getDescription(); out << " n" << get_proc_id(*processor) << "[label=<\n"; out << " \n"; @@ -196,9 +198,10 @@ void printExecutionAnalysis(const Processors & processors, WriteBuffer & out) { out << " \n"; out << " \n"; out << " \n"; @@ -220,7 +223,8 @@ void printExecutionAnalysis(const Processors & processors, WriteBuffer & out) { const IProcessor & next = port.getInputPort().getProcessor(); const auto curr_stats = curr.getProcessorDataStats(); - out << " n" << get_proc_id(curr) << " -> n" << get_proc_id(next) << " [label=\"" << curr_stats.output_rows << " rows\n " << curr_stats.output_bytes << " bytes\"];\n"; + out << " n" << get_proc_id(curr) << " -> n" << get_proc_id(next) << " [label=\"" << curr_stats.output_rows << " rows\n " + << curr_stats.output_bytes << " bytes\"];\n"; } } out << "}\n";
\n"; out << " \n"; - out << " \n"; + out << " \n"; out << " \n"; - out << " \n"; + out << " \n"; out << "
Input wait time(us): " << processor->getInputWaitElapsedNs() / 1000U << "
Input wait time(us): " << processor->getInputWaitElapsedNs() / 1000U << "
Execution time(us): " << processor->getElapsedNs() / 1000U << "
Output wait time(us): " << processor->getOutputWaitElapsedNs() / 1000U << "
Output wait time(us): " << processor->getOutputWaitElapsedNs() / 1000U + << "
\n"; out << "