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 - long query time mysql - log-slow-queries - mysql long-query-time - mysql long_query_time - slow query time - mysql max query time - mysql query time limit - long_query_time mysql - long-query-time mysql - mysql maximum query time - log-slow-queries mantis - mysql slow query time - log slow queries - slow query log my.cnf - 5.0 long query time my.cnf - mysql long query - console mysql set slow_query_time variable - mysql set query time limit - mysql_query trop long - "slow query time" mysql - mysql freebsd query too slow - mysql sql query log timing - query time setting - g mysql set_time_limit - 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 - long query - mysql_query time limit - mysql abort queries that take too long - mysql set long_query_time; - mysql Query_time - query long time in dotnetnuke - set execution time mysql - wordpress mysql queries long time - change long query time - log-slow-queries my.ini - long query time - my.cnf long-query-time - mysql long query setting - mysql+slow query+time precision - mysql_query time limit - mysql default slow query time - set time limit mysql - xampp "log slow queries" -