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.

My website is being very slow or non-responsive. A quick look at the top command shows me something like this:

PID  USER      PR  NI  VIRT  RES  SHR  S %CPU  %MEM    TIME+  COMMAND
1709 mysql     20   0  828m  432m 5584 S 382.6  5.4   7414:24 mysqld

The rest of the processes are way below those values. Obviously MySQL is having some issues. How can I check what is actually going on and why does it take so many resources?

Thanks.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

Run show processlist in the mysql console to get a list of the currently-running queries. Look for ones which have been running for a while, to see what they're doing. Chances are there's a few queries doing monster amounts of work (usually due to poor indexes).

share|improve this answer
    
Thanks that helped :) –  6bytes Nov 25 '09 at 17:41

Apart from womble's answer (which point to optimizing your queries); for those that find 382.6% CPU usage puzzling, note that MySQL is a multithreaded server. It probably was running 4 threads full-tilt, almost monopolizing 4 cores (i'm sure it can do even more in a big enough machine). Pressing 'H' on top shows each thread separately.

share|improve this answer

You should also have a look at the slow log of mysql, if it is enabled.

share|improve this answer
    
Yes I did check that and found out that the file is over 200MB of never seen data. I have a lot of optimizing to do now. –  6bytes Nov 26 '09 at 15:37

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.