基本上我有这个简单的查询:
UPDATE beststat
SET rawView = rawView + 1
WHERE bestid = 139664 AND period = 201205
LIMIT 1
需要1 秒。
该表( beststat)目前有约 100 万条记录,其大小为:68MB。我有4GB RAM和innodb buffer pool size
= 104,857,600,其中: Mysql: 5.1.49-3
这是我数据库中唯一的 InnoDB 表(其他是 MyISAM)
我unique key index
当然有最佳状态和时期:
CREATE TABLE `beststat` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`bestid` int(11) unsigned NOT NULL,
`period` mediumint(8) unsigned NOT NULL,
`view` mediumint(8) unsigned NOT NULL DEFAULT '0',
`rawView` mediumint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `bestid` (`bestid`,`period`)
) ENGINE=InnoDB AUTO_INCREMENT=2020577 DEFAULT CHARSET=utf8
EXPLAIN SELECT rawView FROM beststat WHERE bestid =139664 AND period =201205 LIMIT 1
给出:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE beststat const bestid bestid 7 const,const 1
有什么帮助吗?