How to enable the MySQL slow query log and analyze it?
Connect to a Plesk server via RDP.
Open the MySQL installation folder. In Plesk for Windows, it is
my.inifile located in this folder and add the following lines under the
slow_query_log = 1
slow_query_log_file = slow-query.log
long_query_time = 2
- where long_query_time – time taken by an SQL query to be executed in seconds. If a query takes longer than the value specified, this query will be recorded in the slow query log file.
In the same folder create the file
Restart MySQL via Task Manager > Services or using Plesk Services Monitor:
Once restarted, start monitoring the slow query logfile
slow-query.logcreated on step 4.
To learn more about the MySQL slow query log, visit MySQL 5.7 Reference Manual: The Slow Query Log.