Attempts to test this feature are meeting with limited success.
The goal is always log truly slow queries, which we consider 1 second or more, and to also log a representative sample of all other queries, which on this test system would be 1 in 100. On production it would be 1/1000 or more.
To start I take a pretty much default 5.6 instance of Percona Server and enable slow logging (long_query_time is set to 1) and add this.
mysql> set global log_slow_rate_type =“query”;
Query OK, 0 rows affected (0.00 sec)
mysql> set global log_slow_rate_limit = 100;
Query OK, 0 rows affected (0.00 sec)
mysql> set global slow_query_log_use_global_control =“all”;
Query OK, 0 rows affected (0.00 sec)
Here’s all the variables related to slow logging
show variables like ‘%slow%’;
±-----------------------------------±-----------------------------------------------------------------------+
| Variable_name | Value |
±-----------------------------------±-----------------------------------------------------------------------+
| log_slow_admin_statements | OFF |
| log_slow_filter | |
| log_slow_queries | ON |
| log_slow_rate_limit | 100 |
| log_slow_rate_type | query |
| log_slow_slave_statements | OFF |
| log_slow_sp_statements | ON |
| log_slow_verbosity | microtime,query_plan,innodb |
| slow_launch_time | 2 |
| slow_query_log | ON |
| slow_query_log_always_write_time | 1.000000 |
| slow_query_log_file | /datastore/mysql/devdb-slow.log |
| slow_query_log_timestamp_always | ON |
| slow_query_log_timestamp_precision | microsecond |
| slow_query_log_use_global_control | log_slow_filter,log_slow_rate_limit,log_slow_verbosity,long_query_time |
±-----------------------------------±-----------------------------------------------------------------------+
15 rows in set (0.00 sec)
This was enabled on a test database that runs tens to hundreds of queries per second, so I would have expected a query to be logged every 1-10 seconds. However in the first 24 hours this ran, only four queries showed up in the slow log.
There must be something simple that I am missing.
The log entries do have the expected comments about the rate type and limit, which shows that the system is aware of the config.