views:

14

answers:

1

Is there something i can use to track how long my mysql queries take? perhaps log them if they take > a certain amount of time? or track all queries but only hold the longest query time? using this with C# .NET with ASP.NET.

I'd like to use this to occasionally check if my queries are getting slow.

+2  A: 

This is best done on the server.

MySQL allows you to log queries that take longer than X seconds (where you get to specify X) to a special, slow query log.

under the [mysqld] section in your my.cnf file, add and modify according to taste:

log_slow_queries       = /var/log/mysql/mysql-slow.log #where to log
long_query_time = 2 #time in seconds

http://dev.mysql.com/doc/refman/5.1/en/slow-query-log.html

Roadmaster