In our recent release of Aiven for MySQL we have introduced another advanced configuration which can be enabled by the customers.

Users can now set slow_query_log and long_query_time config options from Advanced Configuration section of their running MySQL service.

To create a MySQL instance please follow this detailed tutorial here. After successfully creating a new MySQL service, go to the Advanced Configuration section of your deployment as shown below:

Enable slow_query_log and set long_query_time to 2s. These two settings will tell MySQL to log any query which takes over 2s to execute. After this, connect to your running MySQL instance using your favorite tool like mysqlsh or via containers using podman/docker. In the following example, we will show you how can this be achieved using podman/docker (we are using this as an alternative to mysqlsh client ).

Copy the connection details from your running service.

Now run the following command ( change the host and port to match your service).

podman run --rm -it mysql:8.0 mysql -u avnadmin --host --port 19539 --database defaultdb --password 

Simulate a slow query:

mysql> select sleep(3);
| sleep(3) |
| 0 |
1 row in set (3.03 sec)

Check if the slow query has been logged:

mysql> select convert(sql_text using utf8) as slow_query, query_time from mysql.slow_log;

| slow_query | query_time |
| select sleep(3) | 00:00:03.000450 |
1 row in set, 1 warning (0.03 sec)

WARNING: Disabling the slow_query_logging setting, will truncate mysql.slow_log table. Please do not forget to back up the data from mysql.slow_log table in case you need it for further analysis.

Did this answer your question?