Enable slow query log in MySQL
Answer:
Turn on the Slow Query log in MySQL allow you to debug the sources of slow and problematic SQL.
To activate it, edit the MySQL configurations, e.g. /etc/my.cnf
[mysqld]
...
...
log-slow-queries = /var/log/mysqld-slow.log
long_query_time = 5
Restart MySQL and you will notice the file mysqld-slow.log will be created.
Any queries take more than 5 seconds to execute will be logged in this file.