I've set up slow query logging for MySQL 5.7:
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow_query_log.log
long_query_time = 10
log_queries_not_using_indexes = 0
Then to test it, I've used MySQL Workbench and ran select sleep(12); and then verified that vim /var/log/mysql/slow_query_log.log shows that query.
So I thought everything was great. However, my slow_query_log seems to work only for my test queries such as select sleep(12); and not for real queries.
Below is an example. In some spots in my Laravel PHP app, I call \DB::enableQueryLog(); and then Log::debug(\DB::getQueryLog()); after running a query, and in those logs I see extremely slow queries (241 seconds!?), but I've never seen them in the slow_query_log.log.
array (
'query' => 'select * from `automations` where (`contact_id` = ? and `job_class_name` = ? and `execute_at` = ?) and `automations`.`deleted_at` is null limit 1',
'bindings' =>
array (
0 => 23030,
1 => 'App\\Jobs\\SubscribeToWebinarFollowupEmailSeries',
2 => '2018-12-30 19:13:00',
),
'time' => 241.37,
),
How can I fix this?
P.S. I don't think my question is a duplicate of this one because in my tests the logging does work.