Updated on 2025-10-28 GMT+08:00

long_query_time Changes Fail to Take Effect

Scenario

After the value of long_query_time was changed from 0.1s to 0.2s on the console, slow query logs still contained slow SQL statements whose execution duration was less than 0.2s.

Possible Causes

Changes to long_query_time on the console take effect globally. After the value of long_query_time is changed, new connections use the new value, but old connections still use the original value (0.1s in this case). Therefore, slow SQL queries whose execution duration was less than 0.2s were generated for old connections.

This problem is caused by the MySQL engine. Changing any of the parameters that take effect on all databases may also have this problem.

Solution

If you require certain session connections to use the new value after long_query_time is changed, close the session connections and re-establish new connections.