Skip to content

Commit a20eccb

Browse files
cerebellumkingqijun-niu-timeplus
authored andcommitted
Ignore internal query in statistics of select query
1 parent 72c1db9 commit a20eccb

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

programs/client/Client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ std::vector<String> Client::loadWarningMessages()
338338
return {};
339339

340340
std::vector<String> messages;
341-
connection->sendQuery(connection_parameters.timeouts, "SELECT message FROM system.warnings SETTINGS _tp_internal_system_open_sesame=true",
341+
connection->sendQuery(connection_parameters.timeouts, "SELECT message FROM system.warnings SETTINGS _tp_internal_system_open_sesame=true,is_internal=true",
342342
{} /* query_parameters */,
343343
"" /* query_id */,
344344
QueryProcessingStage::Complete,

src/Client/Suggest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ static String getLoadSuggestionQuery(Int32 suggestion_limit, bool basic_suggesti
9090
query << "SELECT DISTINCT name FROM system.dictionaries LIMIT " << limit_str
9191
<< " UNION ALL ";
9292
}
93-
query << "SELECT DISTINCT name FROM system.columns LIMIT " << limit_str << " SETTINGS _tp_internal_system_open_sesame=true";
93+
query << "SELECT DISTINCT name FROM system.columns LIMIT " << limit_str << " SETTINGS _tp_internal_system_open_sesame=true,is_internal=true";
9494
}
95-
query << ") WHERE not_empty(res) SETTINGS _tp_internal_system_open_sesame=true";
95+
query << ") WHERE not_empty(res) SETTINGS _tp_internal_system_open_sesame=true,is_internal=true";
9696

9797
return query.str();
9898
}

src/Core/Settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
844844
M(Int64, async_ingest_block_timeout_ms, 120000, "Max duration for a block to commit before it is considered expired during async ingestion", 0) \
845845
M(UInt64, aysnc_ingest_max_outstanding_blocks, 10000, "Max outstanding blocks to be committed during async ingestion", 0) \
846846
M(Bool, _tp_internal_system_open_sesame, true, "Control the access to system.* streams", 0) \
847+
M(Bool, is_internal, false, "Control the statistics of select query", 0) \
847848
M(UInt64, javascript_max_memory_bytes, 100 * 1024 * 1024, "Maximum heap size of javascript UDA/UDF in bytes", 0) \
848849
M(Bool, enable_dependency_check, true, "Enable the dependency check of view/materialized view", 0) \
849850
M(RecoveryPolicy, recovery_policy, RecoveryPolicy::Strict, "Default recovery policy for materialized view when inner query failed. 'strict': always recover from checkpointed; 'best_effort': attempts to recover from checkpointed and allow skipping of some data with permanent errors;", 0) \

src/Interpreters/InterpreterFactory.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,13 @@ std::unique_ptr<IInterpreter> InterpreterFactory::get(ASTPtr & query, ContextMut
134134
else if (query->as<ASTSelectWithUnionQuery>())
135135
{
136136
auto interpreter = std::make_unique<InterpreterSelectWithUnionQuery>(query, context, options);
137-
ProfileEvents::increment(ProfileEvents::SelectQuery);
138-
ProfileEvents::increment(interpreter->isStreamingQuery() ? ProfileEvents::StreamingSelectQuery : ProfileEvents::HistoricalSelectQuery);
137+
138+
if(!options.is_internal && !context->getSettingsRef().is_internal)
139+
{
140+
ProfileEvents::increment(ProfileEvents::SelectQuery);
141+
ProfileEvents::increment(interpreter->isStreamingQuery() ? ProfileEvents::StreamingSelectQuery : ProfileEvents::HistoricalSelectQuery);
142+
}
143+
139144
return std::move(interpreter);
140145
}
141146
else if (query->as<ASTSelectIntersectExceptQuery>())

0 commit comments

Comments
 (0)