2

为了优化 magento,我们在 mysql 中启用了慢查询日志。

query_long_time 的理想值是什么,尤其是对于 magento?

4

2 回答 2

3

默认情况下,我总是将 long_query_time 设置为某个较高的值,例如 60 秒甚至更高。因此,通常的行为将是非常低的开销,因为它不经常写入日志。我当然希望您的大多数查询花费的时间少于 60 秒,但使用 Magento 可能并非如此。:-)

然后当我想收集要分析的日志时,我将 long_query_time 临时更改为 0,因此日志包含所有查询。然后在收集完日志后将其重新设置。

我写了一个脚本来帮助自动化这个过程: https ://github.com/billkarwin/bk-tools/blob/master/full-slow-log

于 2013-06-13T16:08:29.737 回答
1

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_time seconds to execute and required at least min_examined_row_limit rows to be examined. The minimum and default values of long_query_time are 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.

于 2014-08-02T03:42:14.550 回答