2

Is there any way to see an overview of what kind of queries are spent the most time on every day on MySQL?

CCovey
  • 799
  • 1
  • 10
  • 17
Bemmu
  • 17,849
  • 16
  • 76
  • 93

3 Answers3

5

Yes, mysql can create a slow query log. You'll need to start mysqld with the --log-slow-queries flag:

mysqld --log-slow-queries=/path/to/your.log

Then you can parse the log using mysqldumpslow:

mysqldumpslow /path/to/your.log

More info is here (http://dev.mysql.com/doc/refman/5.0/en/slow-query-log.html).

Gordon Wilson
  • 26,244
  • 11
  • 57
  • 60
1

You can always set up query logging as described here:
http://dev.mysql.com/doc/refman/5.0/en/query-log.html

petr k.
  • 8,040
  • 7
  • 41
  • 52
1

It depends on what you mean by 'most time'. There may be thousands if not hundreds of thousands of queries which take very little time each, but consume 90% of CPU/IO bandwidth. Or there may be a few huge outliers. There are tools for performance monitoring and analysis, such as the built-in PERFORMANCE_SCHEMA, the enterprise tools from the Oracle/MySQL team, and online services like newrelic which can track performance of an entire application stack.

Kostja
  • 1,607
  • 10
  • 17