Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple UPDATE query in MySQL take a long time

Tags:

php

mysql

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?

like image 943
stefek143 Avatar asked Nov 13 '22 18:11

stefek143


1 Answers

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

like image 65
Arriane zafe Avatar answered Nov 15 '22 07:11

Arriane zafe