HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMajor

Setting MySQL slow query to less than 1 second

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
querythanslowsettingmysqllesssecond

Problem

I have a heavily loaded LAMP system serving about 40 requests per second and doing about 300 MySQL queries per second. Here is the output of MySQLAdmin status:

Uptime: 5051  Threads: 1  Questions: 1418500  Slow queries: 0  Opens: 456  
Flush tables: 1  Open tables: 450  Queries per second avg: 280.835


However, the global status show about 5-10% table lock contention.

So, I want to figure out the queries that are taking longer time.

Is it possible to set the slow query log to less than one second? For my queries, even execution time of 100ms is high.

Solution

Just set long_query_time to the value you want. If you want to log queries that take longer than 100ms, you would set it to 0.1.

The ability to set this option to a value less than 1 was added in MySQL 5.1.21.

Context

StackExchange Database Administrators Q#43067, answer score: 23

Revisions (0)

No revisions yet.