[英]Simple MySql update query very slow
Following query is taking very long time, although it should execute instantly:以下查询需要很长时间,尽管它应该立即执行:
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
I tried profiling the query, you can see it executes the update fast but then it hangs for some reason:我尝试分析查询,您可以看到它快速执行更新但随后由于某种原因挂起:
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)
I tried mounting the tmp directory to RAM, to speed up queries, but that did not help either.我尝试将 tmp 目录挂载到 RAM 以加快查询速度,但这也无济于事。
I found that if I FLUSH the table, the problem goes temporarily away, but again it comes back after some time.我发现如果我 FLUSH 表,问题会暂时消失,但一段时间后又会出现。
Any help is appreciated.任何帮助表示赞赏。
Resolved - turns out the mysql cache size was too large.已解决 - 结果表明 mysql 缓存大小太大。 Lowering it's size fixed the problem.降低它的大小解决了这个问题。
If this is a MyISAM table you may want to repair it.如果这是一个 MyISAM 表,您可能需要修复它。 I had this phenomenon with corrupt data files.我有这种损坏数据文件的现象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.