Skip to content

Commit b769206

Browse files
committed
Minor micro-optimizations
1 parent 526a14d commit b769206

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

src/Common/OpenTelemetryTraceContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct TracingContextHolder
153153
using TracingContextHolderPtr = std::unique_ptr<TracingContextHolder>;
154154

155155
/// A span holder that creates span automatically in a (function) scope if tracing is enabled.
156-
/// Once it's created or destructed, it automatically maitains the tracing context on the thread that it lives.
156+
/// Once it's created or destructed, it automatically maintains the tracing context on the thread that it lives.
157157
struct SpanHolder : public Span
158158
{
159159
explicit SpanHolder(std::string_view, SpanKind _kind = SpanKind::INTERNAL);

src/Interpreters/executeQuery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void logQueryFinishImpl(
632632

633633
}
634634

635-
if (query_span)
635+
if (query_span && query_span->isTraceEnabled())
636636
{
637637
query_span->addAttribute("db.statement", elem.query);
638638
query_span->addAttribute("clickhouse.query_id", elem.client_info.current_query_id);

src/Planner/Planner.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ void Planner::buildQueryPlanIfNeeded()
13171317
return;
13181318

13191319
LOG_TRACE(
1320-
getLogger("Planner"),
1320+
log,
13211321
"Query to stage {}{}",
13221322
QueryProcessingStage::toString(select_query_options.to_stage),
13231323
select_query_options.only_analyze ? " only analyze" : "");
@@ -1483,7 +1483,7 @@ void Planner::buildPlanForQueryNode()
14831483

14841484
auto & mutable_context = planner_context->getMutableQueryContext();
14851485
mutable_context->setSetting("allow_experimental_parallel_reading_from_replicas", Field(0));
1486-
LOG_DEBUG(getLogger("Planner"), "Disabling parallel replicas to execute a query with IN with subquery");
1486+
LOG_DEBUG(log, "Disabling parallel replicas to execute a query with IN with subquery");
14871487
}
14881488
}
14891489

@@ -1520,9 +1520,7 @@ void Planner::buildPlanForQueryNode()
15201520
if (settings[Setting::allow_experimental_parallel_reading_from_replicas] >= 2)
15211521
throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "FINAL modifier is not supported with parallel replicas");
15221522

1523-
LOG_DEBUG(
1524-
getLogger("Planner"),
1525-
"FINAL modifier is not supported with parallel replicas. Query will be executed without using them.");
1523+
LOG_DEBUG(log, "FINAL modifier is not supported with parallel replicas. Query will be executed without using them.");
15261524
auto & mutable_context = planner_context->getMutableQueryContext();
15271525
mutable_context->setSetting("allow_experimental_parallel_reading_from_replicas", Field(0));
15281526
}
@@ -1537,7 +1535,7 @@ void Planner::buildPlanForQueryNode()
15371535
if (settings[Setting::allow_experimental_parallel_reading_from_replicas] >= 2)
15381536
throw Exception(ErrorCodes::SUPPORT_IS_DISABLED, "JOINs are not supported with parallel replicas");
15391537

1540-
LOG_DEBUG(getLogger("Planner"), "JOINs are not supported with parallel replicas. Query will be executed without using them.");
1538+
LOG_DEBUG(log, "JOINs are not supported with parallel replicas. Query will be executed without using them.");
15411539

15421540
auto & mutable_context = planner_context->getMutableQueryContext();
15431541
mutable_context->setSetting("allow_experimental_parallel_reading_from_replicas", Field(0));
@@ -1568,7 +1566,7 @@ void Planner::buildPlanForQueryNode()
15681566
query_node_to_plan_step_mapping.insert(mapping.begin(), mapping.end());
15691567

15701568
LOG_TRACE(
1571-
getLogger("Planner"),
1569+
log,
15721570
"Query from stage {} to stage {}{}",
15731571
QueryProcessingStage::toString(from_stage),
15741572
QueryProcessingStage::toString(select_query_options.to_stage),

src/Planner/Planner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class Planner
7575

7676
void buildPlanForQueryNode();
7777

78+
LoggerPtr log = getLogger("Planner");
7879
QueryTreeNodePtr query_tree;
7980
SelectQueryOptions & select_query_options;
8081
PlannerContextPtr planner_context;

0 commit comments

Comments
 (0)