1

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.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
6bytes
  • 805
  • 2
  • 10
  • 15

3 Answers3

2

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).

womble
  • 96,255
  • 29
  • 175
  • 230
1

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.

Javier
  • 9,268
  • 2
  • 24
  • 24
0

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

tex
  • 889
  • 1
  • 9
  • 19
  • 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