简体   繁体   English

MySQL中的简单UPDATE查询需要很长时间

[英]simple UPDATE query in MySQL take a long time

I have a problem with simple update query what always appearing in my mysql-slow-query.log table is not big and contain just only 3021 rows . 我有一个简单的更新查询的问题,我的mysql-slow-query.log表中出现的总是不大,只包含3021 rows

the query looks like : 查询看起来像:

UPDATE 'address' 
SET 'user' = 1013 
WHERE 'id_adress' = '1' 
    AND 'date' = '2012-06-04'

Query_time: 2.664413 Lock_time: 0.000043 Rows_sent: 0 Rows_examined: 1 Query_time:2.664413 Lock_time:0.000043 Rows_sent:0 Rows_examined:1

when I examinate this query with: 当我用以下方法检查此查询时:

select  'user' = 1013 
from 'address' 
where  'id_adress' = '1' 
   AND 'date' = '2012-06-04'

then looks very fast 1 row in set (0.00 sec) 然后看起来非常快1 row in set (0.00 sec)

Why this simple update query take such a lot of time? 为什么这个简单的更新查询花了这么多时间? How to fix it? 怎么解决?

first check if your table is not crashed, 首先检查你的桌子是否没有坠毁,
if it is then repair your the table. 如果它然后修复你的表。

second try to index those two fields used in where clause 第二次尝试索引where子句中使用的那两个字段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM