MySQL using 103% CPU

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

MySQL using 103% CPU

Post by JKM »

The MySQL process is using a lot of CPU time, even though theres only one query listed after writing SHOW PROCESSLIST;

Code: Select all

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
24234 mysql     20   0  461m 166m 6152 S   103  2.1  10:08.92 mysqld

Code: Select all

Server version: 5.0.51a-24+lenny4-log (Debian)
mysql> SHOW PROCESSLIST;
+------+----------+------------------+----------+---------+------+-------+------------------+
| Id   | User     | Host             | db       | Command | Time | State | Info             |
+------+----------+------------------+----------+---------+------+-------+------------------+
|  902 | mysqlusr | 11.11.11.1:33582 | mydatabs | Sleep   |  632 |       | NULL             |
| 1328 | root     | localhost        | NULL     | Query   |    0 | NULL  | show processlist |
+------+----------+------------------+----------+---------+------+-------+------------------+
2 rows in set (0.00 sec)
I'm running Debian GNU/Linux 5.0, and I'm having 8 * Intel Xeon X5450 @ 3GHz and 6 GB RAM. I've tried to restart the mysql process, and reboot my machine. It holds at like 1% in 5 minutes, but suddently, it's up to 90-120%, and it stays that way until i restart the mysql process.
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: MySQL using 103% CPU

Post by JakeJ »

Divide by 8 and you have your real answer.

If you use the top command then press 1, it will break out each CPU. As it stands, it can go up to 800%.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: MySQL using 103% CPU

Post by VladSun »

Run "uptime"
Its output looks like this:

Code: Select all

uptime
 10:21:16 up  1:05,  2 users,  load average: 0.57, 0.45, 0.52
The three load average values should be less than the number of CPUs you have.
There are 10 types of people in this world, those who understand binary and those who don't
JKM
Forum Contributor
Posts: 221
Joined: Tue Jun 17, 2008 8:12 pm

Re: MySQL using 103% CPU

Post by JKM »

Code: Select all

uptime
 02:02:16 up 7 days, 16:53,  3 users,  load average: 2.40, 1.96, 0.79
@JakeJ: java is using ~9% and it's running a pretty big program, so I think 103% is pretty high no matter what :p
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: MySQL using 103% CPU

Post by JakeJ »

You're right, 103 still seems to be pretty high, but I've also read that it doesn't always report accurately. Look around for some discussion on the matter. There are some third party monitoring tools that are more accurate.
Post Reply