简体   繁体   中英

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 .

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

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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