From a20eccb3698d88c50902a94859a3721ddeca8081 Mon Sep 17 00:00:00 2001 From: cerebellumking <83447519+cerebellumking@users.noreply.github.com> Date: Fri, 24 May 2024 07:23:15 +0800 Subject: [PATCH] Ignore internal query in statistics of select query --- programs/client/Client.cpp | 2 +- src/Client/Suggest.cpp | 4 ++-- src/Core/Settings.h | 1 + src/Interpreters/InterpreterFactory.cpp | 9 +++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/programs/client/Client.cpp b/programs/client/Client.cpp index 7358dec9285..5634a4998d4 100644 --- a/programs/client/Client.cpp +++ b/programs/client/Client.cpp @@ -338,7 +338,7 @@ std::vector Client::loadWarningMessages() return {}; std::vector messages; - connection->sendQuery(connection_parameters.timeouts, "SELECT message FROM system.warnings SETTINGS _tp_internal_system_open_sesame=true", + connection->sendQuery(connection_parameters.timeouts, "SELECT message FROM system.warnings SETTINGS _tp_internal_system_open_sesame=true,is_internal=true", {} /* query_parameters */, "" /* query_id */, QueryProcessingStage::Complete, diff --git a/src/Client/Suggest.cpp b/src/Client/Suggest.cpp index 032806763b1..94f43b2d9bc 100644 --- a/src/Client/Suggest.cpp +++ b/src/Client/Suggest.cpp @@ -90,9 +90,9 @@ static String getLoadSuggestionQuery(Int32 suggestion_limit, bool basic_suggesti query << "SELECT DISTINCT name FROM system.dictionaries LIMIT " << limit_str << " UNION ALL "; } - query << "SELECT DISTINCT name FROM system.columns LIMIT " << limit_str << " SETTINGS _tp_internal_system_open_sesame=true"; + query << "SELECT DISTINCT name FROM system.columns LIMIT " << limit_str << " SETTINGS _tp_internal_system_open_sesame=true,is_internal=true"; } - query << ") WHERE not_empty(res) SETTINGS _tp_internal_system_open_sesame=true"; + query << ") WHERE not_empty(res) SETTINGS _tp_internal_system_open_sesame=true,is_internal=true"; return query.str(); } diff --git a/src/Core/Settings.h b/src/Core/Settings.h index e2fb8e4b7c6..8b1a5d1eda0 100644 --- a/src/Core/Settings.h +++ b/src/Core/Settings.h @@ -844,6 +844,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value) M(Int64, async_ingest_block_timeout_ms, 120000, "Max duration for a block to commit before it is considered expired during async ingestion", 0) \ M(UInt64, aysnc_ingest_max_outstanding_blocks, 10000, "Max outstanding blocks to be committed during async ingestion", 0) \ M(Bool, _tp_internal_system_open_sesame, true, "Control the access to system.* streams", 0) \ + M(Bool, is_internal, false, "Control the statistics of select query", 0) \ M(UInt64, javascript_max_memory_bytes, 100 * 1024 * 1024, "Maximum heap size of javascript UDA/UDF in bytes", 0) \ M(Bool, enable_dependency_check, true, "Enable the dependency check of view/materialized view", 0) \ 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) \ diff --git a/src/Interpreters/InterpreterFactory.cpp b/src/Interpreters/InterpreterFactory.cpp index 4e7e6e72892..e41676dbfda 100644 --- a/src/Interpreters/InterpreterFactory.cpp +++ b/src/Interpreters/InterpreterFactory.cpp @@ -134,8 +134,13 @@ std::unique_ptr InterpreterFactory::get(ASTPtr & query, ContextMut else if (query->as()) { auto interpreter = std::make_unique(query, context, options); - ProfileEvents::increment(ProfileEvents::SelectQuery); - ProfileEvents::increment(interpreter->isStreamingQuery() ? ProfileEvents::StreamingSelectQuery : ProfileEvents::HistoricalSelectQuery); + + if(!options.is_internal && !context->getSettingsRef().is_internal) + { + ProfileEvents::increment(ProfileEvents::SelectQuery); + ProfileEvents::increment(interpreter->isStreamingQuery() ? ProfileEvents::StreamingSelectQuery : ProfileEvents::HistoricalSelectQuery); + } + return std::move(interpreter); } else if (query->as())