简体   繁体   中英

Mysql performance issue with INNODB

I have a very strange performance problem with some databases on my linux webserver. First:

  • the problem occures in different INNODB tables
  • only 10 - 15000 entries in the tables
  • indexed correctly
  • happens only once or twice a day

The following query is very slow (just from time to time):

UPDATE t_contentlocks 
SET  lastaccess = NOW(),  has_write_access = '1'  
WHERE id = '10'

the field "id" is the primary (integer) and the table has about 20 entries. How can such a query take 30s to be handled? There were no other queries at this time. It looks/feels like the mysql server went into some kind of hibernation mode and now needs time to wake up again. Normally this query takes less than 0.00001s.

Does someone have the same problem / any fix for it?

Thanks!

You do query id = '10' , the id is an int. Each time the query is runned the ids will be converted to varchar, and the indez will not be user. So it will be much faster to do:

WHERE id = 10

Now the index will be user, I'm not sure it will fix your 30 second problem.

Apart from peer answer you can also check the profiling the query then you take proper decision by looking where query execution takes more time .

 SET PROFILING=1;
UPDATE t_contentlocks 
SET  lastaccess = NOW(),  has_write_access = '1'  
WHERE id = '10';
show profile for QUERY 1;

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