- 论坛徽章:
- 0
|
回复 9# cenalulu
按照你的说法,就是只要有where条件就Extra必会出现Using where。那么下面这个例又该如何解释?- mysql> show create table T_IN \G
- *************************** 1. row ***************************
- Table: T_IN
- Create Table: CREATE TABLE `T_IN` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `sex` int(11) NOT NULL,
- `age` int(11) NOT NULL,
- `content` varchar(200) DEFAULT NULL,
- PRIMARY KEY (`id`),
- KEY `sex_age` (`sex`,`age`),
- KEY `idx_age` (`age`)
- ) ENGINE=InnoDB AUTO_INCREMENT=262125 DEFAULT CHARSET=utf8
复制代码
- mysql> analyze local table T_IN;
- +-----------+---------+----------+----------+
- | Table | Op | Msg_type | Msg_text |
- +-----------+---------+----------+----------+
- | test.T_IN | analyze | status | OK |
- +-----------+---------+----------+----------+
- 1 row in set (0.00 sec)
复制代码
- mysql> select count(*) from T_IN;
- +----------+
- | count(*) |
- +----------+
- | 131072 |
- +----------+
复制代码- mysql> select count(*) from T_IN where age = 21;
- +----------+
- | count(*) |
- +----------+
- | 9871 |
- +----------+
复制代码- mysql> explain select age from T_IN where age =21;
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------------+
- | 1 | SIMPLE | T_IN | ref | idx_age | idx_age | 4 | const | 9870 | Using index |
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------------+
复制代码- mysql> explain select * from T_IN where age =21;
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------+
- | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------+
- | 1 | SIMPLE | T_IN | ref | idx_age | idx_age | 4 | const | 9870 | |
- +----+-------------+-------+------+---------------+---------+---------+-------+------+-------+
复制代码 同样SQL后面有where,Extra列就没有显示Using where. 不知道是不是我没明白你说的意思。
|
|