Search code examples
mysql-8.0mysql-slow-query-log

MySQL 8 slow query issue


My MySQL 8 conf as below :

[mysqld]
slow_query_log = ON
long_query_time = 5
log_slow_admin_statements = 1
log_queries_not_using_indexes = 1

But when I got slow query log in my table that will show : enter image description here

The query time do not match long_query_time (5s)

Any ideas ?


Solution

  • You have just found out why I recommend turning this off

    log_queries_not_using_indexes = 0
    

    When a tiny table is accessed without an index, it will run fast enough that you should not care, and it should not clutter the log.

    I also recommend a much lower value for this

    long_query_time = 1
    

    pt-query-digest is a good tool for summarizing the data, especially if the log is written to a FILE.