- 论坛徽章:
- 0
|
原帖由 cenalulu 于 2009-12-11 15:09 发表 ![]()
log-queries-not-using-indexes 设置为OFF
低于5s的语句就不会记录了
CREATE TABLE `gamegeneral` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`uid` int(10) unsigned NOT NULL DEFAULT '0',
`generalid` int(10) unsigned NOT NULL DEFAULT '0',
...
PRIMARY KEY (`id`),
UNIQUE KEY `generalid` (`generalid`),
KEY `uid` (`uid`,`cityid`),
KEY `status` (`status`),
KEY `bname` (`bname`)
) ENGINE=InnoDB AUTO_INCREMENT=14138 DEFAULT CHARSET=utf8
mysql> show index from gamegeneral;
+-------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| gamegeneral | 0 | PRIMARY | 1 | id | A | 6663 | NULL | NULL | | BTREE | |
| gamegeneral | 0 | generalid | 1 | generalid | A | 6663 | NULL | NULL | | BTREE | |
| gamegeneral | 1 | uid | 1 | uid | A | 1 | NULL | NULL | | BTREE | |
| gamegeneral | 1 | uid | 2 | cityid | A | 3331 | NULL | NULL | | BTREE | |
| gamegeneral | 1 | status | 1 | status | A | 35 | NULL | NULL | | BTREE | |
| gamegeneral | 1 | bname | 1 | bname | A | 6663 | NULL | NULL | | BTREE | |
+-------------+------------+-----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
6 rows in set (0.01 sec)
# User@Host: root[root] @ localhost []
# Query_time: 0.005975 Lock_time: 0.000081 Rows_sent: 0 Rows_examined: 6898
SET timestamp=1260515581;
SELECT id,uid,class,health,energy,health_sx,energy_sx FROM gamegeneral WHERE uid>0 and health < health_sx or energy<energy_sx;
这个不知算不逄使用了索引 |
|