1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

MDEV-33144 Implement the Percona variable slow_query_log_always_write_time

This task is inspired by the Percona implementation of
slow_query_log_always_write_time.

This task implements the variable log_slow_always_query_time (name
matching other MariaDB variables using the slow query log). The
default value for the variable is 31536000, which makes MariaDB
compatible with older installations.

For queries with execution time longer than log_slow_always_query_time
the variables log_slow_rate_limit and log_slow_min_examined_row_limit
will be ignored and the query will be written to the slow query log
if there is no other limitations (like log_slow_filter etc).

Other things:
- long_query_time internal variable renamed to log_slow_query_time.
- More descriptive information for "log_slow_query_time".
This commit is contained in:
Monty
2023-12-31 12:41:25 +02:00
committed by Sergei Golubchik
parent bf9662f6fa
commit 40810baffe
11 changed files with 154 additions and 31 deletions

View File

@@ -714,7 +714,8 @@ typedef struct system_variables
ulonglong max_heap_table_size;
ulonglong tmp_memory_table_size;
ulonglong tmp_disk_table_size;
ulonglong long_query_time;
ulonglong log_slow_query_time;
ulonglong log_slow_always_query_time;
ulonglong max_statement_time;
ulonglong optimizer_switch;
ulonglong optimizer_trace;
@@ -743,7 +744,8 @@ typedef struct system_variables
ulonglong max_tmp_space_usage;
double optimizer_where_cost, optimizer_scan_setup_cost;
double long_query_time_double, max_statement_time_double;
double log_slow_query_time_double, max_statement_time_double;
double log_slow_always_query_time_double;
double sample_percentage;
ha_rows select_limit;
@@ -4438,9 +4440,14 @@ public:
void update_server_status()
{
set_time_for_next_stage();
if (utime_after_query >= utime_after_lock + variables.long_query_time)
if (utime_after_query >= utime_after_lock + variables.log_slow_query_time)
server_status|= SERVER_QUERY_WAS_SLOW;
}
/* True if query took longer than log_slow_always_query_time */
bool log_slow_always_query_time()
{
return (utime_after_query >= utime_after_lock + variables.log_slow_always_query_time);
}
inline ulonglong found_rows(void)
{
return limit_found_rows;