Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
简单的MySql更新查询非常慢_Mysql_Sql_Sql Update - Fatal编程技术网

简单的MySql更新查询非常慢

简单的MySql更新查询非常慢,mysql,sql,sql-update,Mysql,Sql,Sql Update,以下查询需要很长时间,但应立即执行: mysql> UPDATE articles SET description='test' WHERE article_id=6; Query OK, 1 row affected (40.80 sec) Rows matched: 1 Changed: 1 Warnings: 0 物品id为INT自动递增 表中只有大约1000条记录 我尝试分析查询,您可以看到它快速执行更新,但由于某些原因它挂起: mysql> SHOW PROFIL

以下查询需要很长时间,但应立即执行:

mysql> UPDATE articles SET description='test' WHERE article_id=6;
Query OK, 1 row affected (40.80 sec)
Rows matched: 1  Changed: 1  Warnings: 0
  • 物品id为INT自动递增
  • 表中只有大约1000条记录
我尝试分析查询,您可以看到它快速执行更新,但由于某些原因它挂起:

mysql> SHOW PROFILE FOR QUERY 1;
+----------------------+-----------+
| Status               | Duration  |
+----------------------+-----------+
| starting             |  0.000079 |
| checking permissions |  0.000016 |
| Opening tables       |  0.000020 |
| System lock          |  0.000011 |
| Table lock           |  0.000864 |
| init                 |  0.000078 |
| Updating             |  0.000315 |
| end                  | 40.798736 |
| query end            |  0.000028 |
| freeing items        |  0.000014 |
| closing tables       |  0.000012 |
| logging slow query   |  0.000010 |
| logging slow query   |  0.000046 |
| cleaning up          |  0.000012 |
+----------------------+-----------+
14 rows in set (0.00 sec)
我尝试将tmp目录装载到RAM中,以加快查询速度,但这也没有帮助

我发现,如果我冲洗桌子,问题会暂时消失,但一段时间后又会出现


非常感谢您的帮助。

如果这是MyISAM表,您可能需要修复它。我在损坏的数据文件中遇到了这种现象。

已解决-结果是mysql缓存太大。降低它的大小修复了这个问题。

是否有其他东西同时针对数据库运行?您可能遇到了锁定问题,其他一些查询已锁定了相关行。是的,它是MyISAM。我试过多次修复、优化和冲洗。只有FLUSH可以解决这个问题,但即使是暂时的。第二天,问题又出现了。我还应该提到,这是在一个由一个主服务器和一个从服务器组成的集群上,不确定它是否与问题有关。