The Slow Query Log. The easiest way to do this is to use the slow query log. Because of this it is considered best practice on production systems to disable the slow query log.
MySQL slow query log makes it easy to track SQL queries that take more than a specific time for execution. The slow query logs will show you a list of queries that have been identified as slow based on the given values in the system variables as mentioned earlier. MySQL slow query log can be to used to determine queries that take a longer time to execute in order to optimize them.
Configure slow query logging.
Touch varlibmysqlslowlog chmod 660 varlibmysqlslowlog chown mysqlmysql varlibmysqlslowlog. Slow_query_log 1 slow_query_log_file slow-querylog long_query_time 2. Start monitoring the slow query logfile. To enable the slow query log in MySQL follow these steps.