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.

New Articles

Incoming Search Terms for the Article

mysql long query time - long query time - long-query-time - mysql max query time - mysql long-query-time - mysql slow query time - log-slow-queries - long query time mysql - mysql query takes too long - how to increase mysql response time limit - mysql long_query_time - mysql query time limit - long_query_time mysql - a query is running for long time? - mysql limit query time - mysql set long query time - slow query kill mysql - mysql long query - mysql long queries - log-slow-queries my.cnf - my.cnf query execution time limit - steps to set log-slow-queries - how to find the last long run query mysql server - mysql slow query long_query_time - mysql max slow query time - mysql finding long queries - Mysql JDBC max query time - mysql slow query swap - slow log query time - tiempo recomendado long queries mysql - long_query_time my.cnf - my.cnf query limit - mysql maximum query time - enable slow queries mysql time - enable slow log mysql how to - max query time mysql - mysql Query_time: - mysql long query time - mysql_query trop long - mysql query kill time limit - solid state long queries - long time query sybase - mysql Query_time - mysql slow log queries windows - set time delay in mysql query - slow query query_time unit - change max query time in mysql - php mysql long queries - select mysql long query - set session log_slow_queries -