Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to know if there is anyway I can display the most frequent SQL query on MySQL server in order to memcache it.

share|improve this question
? But MySQL already caches: – symcbean Sep 30 '10 at 14:29
It does but it's still slower than memcached – mnml Sep 30 '10 at 15:24
up vote 1 down vote accepted

You have to enable query logging or you should monitor it trough show processlist; Please see the documentation:

If you pick up the parameters right you can see the queries in the slow query log:

share|improve this answer

check mysqlsla - it can take your query log, parametrize queries and provide you report with query types that show up most often.

share|improve this answer

I'd suggest you set your slow query time to something very small, then run maatkit's mk-query-digest to profile all the logged queries. You may be able to run it on an ordinary log file as well.

There are other maatkit utilities that may be able to help too.

Innotop is a good way of watching what your server is up to - generally easier to keep an eye on than showing the processlist.

share|improve this answer

I've been working with the commercial software package Jet Profiler for MySQL and like it. It's about $400, though there's a trial period.

Otherwise, I log the SQL requests in my application. With Java (my language of choice) you can configure the JDBC Connector/J driver to log all sql requests. Then I do a mix of regexp and hand editing to make it readable and analyze the results.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.