Change or Set MySQL Long Query Time Value for log-slow-queries

If you enable slow queries log of MySQL database server, you will notice that from the slow query log file contains only SQL statements and queries that took more than query_time of 10 seconds to execute or run. This is the default value or query time threshold for log_slow_queries function, which is 10 seconds. 10 seconds is way too long for a SQL query to complete, so the value may be too high to capture any meaningful data. You can alter or change the slow query time to lower value or number of seconds.

You can set a new long_query_time in the MySQL configuration file, namely my.cnf or my.ini, normally located in /etc directory. Simply add the following line to the configuration file:

long_query_time = 5

Above option will set the slow or long query limit as 5 seconds, which means MySQL will capture and log all SQL queries that took longer than 5 seconds to execute and finish running to the log file.


One Response to “Change or Set MySQL Long Query Time Value for log-slow-queries”

  1. Todd
    June 20th, 2007 00:43
    1

    Stating that “10 seconds is way too long for a SQL query to complete” is slightly irresponsible, as 10 seconds might be perfectly reasonable for some queries to complete given the dataset and hardware being queried against combined with the complexity of the query.

    Seeing as how this page is ranking quite high for people having performance issues with MySQL, I feel it is important to set this straight. One should not read this article and assume that their queries are performing unreasonably slow simply because they take over 10 seconds.

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.
Custom Search

New Articles

Incoming Search Terms for the Article

mysql long query time - long query time - long-query-time - log-slow-queries - slow query time - mysql long_query_time - mysql query time limit - mysql maximum query time - mysql slow query threshold - set mysql time limit - mysql query time log - long query time mysql - long_query_time mysql - mysql long-query-time - slow query log my.cnf - all - how to configure mysql long_query_time - limit mysql query time execution - limit mysql query time - log query lambat log_slow_queries - long query mysql - mysql long queries - mysql_query trop long - long query time default mysql - max time for mysql query - mysql long download - mysql max time - mysql slow query time - MySQL tracking long query - set mysql query - set query execution time +mysql - set long query time - slow query log time - time limit for mysql queries - how to change time limit in mysql - limit mysql slow - mysql limit query time - mysql long query time log my.ini - mysql change long_query_time - slow_log microseconds query time mysql freebsd - mysql set slow query threshold - xampp mysql max execute time - query time setting - g mysql set_time_limit - log slow queries - long time query - long_query_time default value - slow-queries time - find which query takes long time - how to change execution time for mysql server -