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.

Share and contribute or get technical support and help at My Digital Life Forums.



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

log-slow-queries - mysql long query time - mysql long_query_time - mysql long queries - mysql max query time - long-query-time mysql - how to log query time in mysql - mysql limit query time - mysql long query - long query time - mysql long_query_time - MYSQL SET LOG-SLOW-QUERIES - long query log - mysql long running queries - mysql set long_query_time - mysql change slow query time - log-slow-queries 5 seconds - max query time mysql - mysql query "time limit" - mysql query limits - mysql "query time limit" - mysql set time limit - vista mysql slow - "long query time" - change query slow - how to set limit to mysql query - limit query time mysql - mysql freebsd log-slow-queries - mysql slow query max - mysql query time limit - mysql time limit query - mysql long quesry time - mysql query limit max - mysql long running queries - mySQL takes a long time to do a query - slow query time limit - access query between Time Value() - limit mysql query time - mysql changing slow query time - mysql slow query time - mysql log slow queries time option - mysql long time query - mysql activate slow queries - set log slow queries - slow log long query - wordpress mysql slow queries - "max query time" - enable slow query logs mysql windows - how to change slow-query-time - mysql long running -