我有以下数据库:
CREATE TABLE IF NOT EXISTS `musics` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`active` tinyint(1) NOT NULL DEFAULT '1',
`slug` varchar(50) NOT NULL,
`movie_id` int(11) NOT NULL,
`added` int(11) NOT NULL,
`updated` int(11) NOT NULL,
`featured` tinyint(1) NOT NULL,
`hits` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `slug` (`slug`),
KEY `active` (`active`),
KEY `featured` (`featured`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3339 ;并在音乐专辑的每个页面加载上运行查询UPDATE musics SET hits = 7 WHERE id = '1770'。有任何方法来优化这个查询吗?
发布于 2013-12-04 15:20:40
就像mysql说的那样:“缓慢的查询日志由超过long_query_time秒的->语句组成”,-> long_query_time是来自mysql的服务器系统变量,也可以更改。
关于优化问题:
你可以不写“= 1770”,因为那是整数,而不是字符串。
发布于 2015-12-02 03:55:13
例如..。
set global long_query_time=1;和,my.cnf
[mysqld]
...
long_query_time=1;你可以用“解释”。
explain select * from musics where id = 1770; https://stackoverflow.com/questions/20377900
复制相似问题