performance - Table update on PK and another field in MySQL is sporadically slow -


this interesting case update in mysql sporadically slow. background: 48gb innodb buffer cache, 512mb ib logs. innodb table 40mln rows. structure , indexes:

create table `visitorcompetition` (   `visitorcompetitionid` bigint(20) not null auto_increment,   `userid` bigint(20) not null,   `competitioninstanceid` bigint(20) not null,   `score` bigint(20) not null default '0',   `visits` bigint(20) default null,   `status` varchar(255) not null,   `rankatcompletion` int(11) default null,   `sessionid` varchar(36) default null,   `shareddate` timestamp null default null,   `createddate` timestamp(6) not null default current_timestamp(6),   `lastmodifieddate` timestamp(6) not null default current_timestamp(6),   `modifiedby` varchar(55) default null,   `caseid` int(11) not null,   primary key (`visitorcompetitionid`),   unique key `uc_userid_competitioninstanceid` (`userid`,`competitioninstanceid`),   key `idx_visitorcompetition_ti_s` (`competitioninstanceid`,`status`),   key `idx_createddate` (`createddate`),   constraint `fk1` foreign key (`competitioninstanceid`)      references `competitioninstance` (`competitioninstanceid`) ) engine=innodb auto_increment=74011154 default charset=utf8 

when there update looks this:

update visitorcompetition  set         status='closed',     score=770000,     visits=null,     rankatcompletion=null,     shareddate=null,     lastmodifieddate=current_timestamp(6),     modifiedby='11.12.12.200'  visitorcompetitionid=99999965 , status = 'closed'; 

note pk in clause , additional field condition. update executes ~20 times/sec. on cases update runs instantaneously few times day takes 100-300 seconds complete , shows slow log. reason behavior?

update #1: ruled out checkpointing, trigger , query cache possible root causes. events_stages_history_long shows 1 of updates:

stage/sql/updating      188.025130 stage/sql/end   0.000004 stage/sql/query end     0.000002 stage/sql/closing tables        0.000004 stage/sql/freeing items 0.000002 stage/sql/logging slow query    0.000032 stage/sql/cleaning   0.000001 

similar problem (but not case): mysql update taking(too) long time

update #2: slow updates in case correlate spikes in mutex contention. seems root cause.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -