大网数据广告活动
服务器运维问答

MySQL extremely slow on very simple SELECT queries

· 52CE 我爱测

We have a simple web application running on a virtual machine that saves its data in a MySQL 5.5 database with the InnoDB engine. Everything worked fine for around three years, but suddenly it became extremely slow. For example, …

问题原文

原帖链接 · tabb · CC BY-SA 3.0

We have a simple web application running on a virtual machine that saves its data in a MySQL 5.5 database with the InnoDB engine. Everything worked fine for around three years, but suddenly it became extremely slow.

For example, I have a very simple table holding addresses:

CREATE TABLE `addresses` (
  `address_id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(64) CHARACTER SET latin1 NOT NULL,
  `firstname` varchar(64) CHARACTER SET latin1 NOT NULL,
  `street` varchar(64) CHARACTER SET latin1 NOT NULL,
  `housenumber` varchar(16) CHARACTER SET latin1 NOT NULL,
  `zip` varchar(5) CHARACTER SET latin1 NOT NULL,
  `city` varchar(64) CHARACTER SET latin1 NOT NULL,
  `email` varchar(64) CHARACTER SET latin1 NOT NULL,
  `phone` varchar(16) CHARACTER SET latin1 NOT NULL,
  `birthdate` date NOT NULL,
  PRIMARY KEY (`address_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin

This table hold around 800 entries which is really not much. But running the query

SELECT * FROM addresses

for test purposes, it seems to never finish. I checked this with the mysql CLI on the server itself: It outputs some rows of the table and then waits very long until it outputs the next rows.

So maybe it is a problem in the data sending phase, but I am not sure.

The VM has 2GB of RAM and only 320MB are used. The CPU also runs at very low 1 to 2%. mytop does not show any other queries that are blocking the server. The IT admin said that they didn't change anything at the hardware side.

I already tried some thing like restarting the database server, restarting the virtual machine. Nothing helped.

edit:

EXPLAIN SELECT * FROM addresses

gives me this result:

+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
| id | select_type | table     | type | possible_keys | key  | key_len | ref  | rows | Extra |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
|  1 | SIMPLE      | addresses | ALL  | NULL          | NULL | NULL    | NULL |  793 |       |
+----+-------------+-----------+------+---------------+------+---------+------+------+-------+
1 row in set (0.00 sec)

社区高分解答

原帖链接 · user3648611 · CC BY-SA 3.0

If the cpu load is low then this indicates that there are no problems with missing indexes, if that was the case the query would just need take more cpu and disk access. Also you said it worked fine for 3 years.

Did you check the general disk access speed (specifically on the partition where the database is located)? E.g. using dd like here. What you're describing sounds like a dead disk or half-dead raid. Got backups i hope?

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-11-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。