mysql - Slow Updates for Single Records by Primary Key -
i using mysql 5.5.
i have innodb table definition follows:
create table `table1` ( `col1` int(11) not null auto_increment, `col2` int(11) default null, `col3` varchar(255) collate utf8_unicode_ci default null, `col4` int(11) default null, `col5` datetime default null, `col6` tinyint(1) not null default '0', `col7` datetime not null, `col8` datetime not null, `col9` int(11) default null, `col10` tinyint(1) not null default '0', `col11` tinyint(1) default '0', primary key (`col1`), unique key `index_table1_on_ci_ai_tn_sti` (`col2`,`col4`,`col3`,`col9`), key `index_shipments_on_applicant_id` (`col4`), key `index_shipments_on_shipment_type_id` (`col9`), key `index_shipments_on_created_at` (`col7`), key `idx_tracking_number` (`col3`) ) engine=innodb auto_increment=7634960 default charset=utf8 collate=utf8_unicode_ci;
the issue updates. there 2m rows in table.
a typical update query :
update table1 set col6 = 1 col1 = 7634912;
we have 5-10k qps on production server. these queries in "updating" state when looked @ through process list. innodb locks show there many rec not gap locks on index_table1_on_ci_ai_tn_sti
. no transaction waiting lock.
my feeling unique index causing lag i'm not sure why. table have defined way using unique index.
i don't think unique
key has impact (in case).
are setting datetime
"1"? (please check other typos -- could make big difference.)
are trying 10k updates
per second?
is innodb_buffer_pool_size
bigger table, no bigger 70% of available ram?
what value of innodb_flush_log_at_trx_commit
? 1 default , secure, slower 2.
can put bunch of updates single transaction? cut down transaction overhead.
Comments
Post a Comment