Why this query is so slow?

Posted by Silver Light on Stack Overflow See other posts from Stack Overflow or by Silver Light
Published on 2011-01-09T18:27:54Z Indexed on 2011/01/09 18:53 UTC
Read the original article Hit count: 203

This query appears in mysql slow query log: it takes 11 seconds.

INSERT INTO record_visits
( record_id, visit_day )
VALUES
( '567', NOW() );

The table has 501043 records and it's structure looks like this:

CREATE TABLE IF NOT EXISTS `record_visits` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `record_id` int(11) DEFAULT NULL,
  `visit_day` date DEFAULT NULL,
  `visit_cnt` bigint(20) DEFAULT '1',
  PRIMARY KEY (`id`),
  UNIQUE KEY `record_id_visit_day` (`record_id`,`visit_day`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

What could be wrong? Why this INSERT takes so long?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about mysql-query