Add setting

This commit is contained in:
Nikolay Degterinsky 2021-08-25 17:41:21 +03:00
parent 884b51116d
commit 2c81a35b4e
2 changed files with 8 additions and 0 deletions

View File

@ -176,6 +176,7 @@ class IColumn;
M(LogQueriesType, log_queries_min_type, QueryLogElementType::QUERY_START, "Minimal type in query_log to log, possible values (from low to high): QUERY_START, QUERY_FINISH, EXCEPTION_BEFORE_START, EXCEPTION_WHILE_PROCESSING.", 0) \
M(Milliseconds, log_queries_min_query_duration_ms, 0, "Minimal time for the query to run, to get to the query_log/query_thread_log/query_views_log.", 0) \
M(UInt64, log_queries_cut_to_length, 100000, "If query length is greater than specified threshold (in bytes), then cut query when writing to query log. Also limit length of printed query in ordinary text log.", 0) \
M(Float, log_queries_probability, 1., "Log queries with the specified probabality.", 0) \
\
M(DistributedProductMode, distributed_product_mode, DistributedProductMode::DENY, "How are distributed subqueries performed inside IN or JOIN sections?", IMPORTANT) \
\

View File

@ -56,6 +56,8 @@
#include <Processors/Formats/IOutputFormat.h>
#include <Processors/Sources/SinkToOutputStream.h>
#include <random>
namespace ProfileEvents
{
@ -659,6 +661,11 @@ static std::tuple<ASTPtr, BlockIO> executeQueryImpl(
elem.client_info = client_info;
std::bernoulli_distribution should_write_log{
settings.log_queries_probability};
context->setSetting("log_queries", should_write_log(thread_local_rng));
bool log_queries = settings.log_queries && !internal;
/// Log into system table start of query execution, if need.