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

When I run "top" command on my Linux it shows that MySQL is taking 400%-500% CPU usage. But when I run "watch mysqladmin pr" command to see a list of queries being run by MySQL then it shows just 2, 3 queries and that too only taking 2, 3 seconds. The "top" command shows MySQL constantly fluctuating CPU usage like 130%, 200%, 340%, 230%, 400%, 440%, 635%, 335% e.t.c. but "watch mysqladmin pr" command is not showing queries that are taking up CPU usage. How do I check why MySQL is using so much CPU?

share|improve this question
first, add top and ps output – alvosu Feb 7 '11 at 8:49
Sorry I didn't get it. Do you want me to run "ps" command? I am new to Linux. – Ali Feb 7 '11 at 9:53

Two things come to mind here :

Observation 1

When MySQL causes a constatntly fluctuating CPU, I would first check what kind of installation of MySQL was performed. MySQL RPMs usually contain binaries that have been optimized for specific platforms. On the other hand, MySQL binaries that have been compiled from source tend not to be lean and mean. Such binaries could be bloated and not optimized at compile time to take advantage of memory.

Observation 2

If the InnoDB Buffer Pool (innodb_buffer_pool_size) or the MyISAM Key Cache (key_buffer_size) is underconfigured or overconfigured, you could potentially be spending time clean out caches without the presence of new queries.

share|improve this answer
I have fixed this problem by optimizing my queries. There were many poor queries with joins that were not using index so I have fixed them. – Ali Apr 5 '11 at 5:09

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.