To optimize magento we enable slow query log in mysql.
What is ideal value for query_long_time especially for magento?
I always set long_query_time to some high value by default, for example 60 seconds or even higher. So the usual behavior would be very low overhead because it's writing to the log infrequently. I certainly hope most of your queries take much less than 60 seconds, but with Magento maybe that's not the case. :-)
Then when I want to collect logs to be analyzed, I change long_query_time to 0 temporarily, so the log contains all queries. Then set it back when you're done collecting logs.
The long_query_time parameter is expressed in seconds, so you could start by setting it to any number of seconds (the default is 10 seconds) and then reviewing the log. If the signal (i.e. slow queries) to noise (i.e. other queries) ratio is too high, set it to a larger number to log only the queries that require more time to complete.
From the 5.7 Reference Manual:
The slow query log consists of SQL statements that took more than
long_query_timeseconds to execute and required at leastmin_examined_row_limitrows to be examined. The minimum and default values oflong_query_timeare 0 and 10, respectively. The value can be specified to a resolution of microseconds. For logging to a file, times are written including the microseconds part. For logging to tables, only integer times are written; the microseconds part is ignored.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With