Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.