indexing - Why would this simple MySQL update query take so long? -



indexing - Why would this simple MySQL update query take so long? -

my host has been sending me messages on lastly few months saying site using way many mysql minutes. send logs showing queries utilize time on occasion. of queries kind of long , complicated, understand why issue. few have me scratching head. 1 want focus on next this:

update parentmessages set views=views+1 parentid='11308'

the number example, parentid. parentmessages table has parentid primary key, think indexed , found. there 11,000 records in table, not many. here numbers host gave me how long query took on 6 instances yesterday:

taking 0.126455 , 1.472929 , 1.638743 , 3.040538 , 7.130041 , 112.498037 seconds complete

the 112 random glitch suppose, why take 3, 7 seconds sometimes?! best bet because have lot of indices on table don't know plenty mysql know if matter. , why 1/10th of sec , many seconds?

here show create table:

create table `parentmessages` ( `parentid` int(7) not null auto_increment, `active` tinyint(1) not null, `level` int(2) not null, `type` varchar(10) not null, `hidden` tinyint(1) default null, `sticky` tinyint(1) not null, `poll` tinyint(1) not null, `topic` varchar(120) default null, `message` varchar(30000) not null, `views` int(6) not null, `replies` int(5) not null, `userid` int(7) not null, `datetimecalc` int(11) not null, `lastreplycalc` int(11) not null, `lastreplyuser` int(7) not null, `editedcalc` int(11) default null, `editeduser` int(7) default null, `realediteduser` int(7) default null, `altint` int(7) default null, `imageurl` varchar(125) default null, `locked` tinyint(1) not null, `tempid` int(12) not null, primary key (`parentid`), key `useridindex` (`userid`), key `datetimecalcindex` (`datetimecalc`), key `activeindex` (`active`), key `lastreplycalcindex` (`lastreplycalc`), key `levelindex` (`level`), key `stickyindex` (`sticky`) ) engine=myisam auto_increment=11716 default charset=latin1

one reason be, slow query blocking table , update waiting other query finish.

mysql indexing sql-update

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -