Quantcast
Channel: MySQL Forums - InnoDB
Viewing all articles
Browse latest Browse all 1954

the where condition field after ">=" can use index? is this true? (no replies)

$
0
0
I have a table T like this
Create Table: CREATE TABLE `T` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) NOT NULL DEFAULT '0',
`c` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `idx_ab` (`a`,`b`)
) ENGINE=InnoDB AUTO_INCREMENT=2048 DEFAULT CHARSET=latin1

I perform this SQL:
explain select * from T force index (idx_ab) where a >= 100 and b = 200;
I guess this sql can use index on a, and the key_len would be 4, but in fact the output key_len is 8, why?
mysql> explain select * from T force index (idx_ab) where a >= 100 and b = 200;
+----+-------------+-------+-------+---------------+--------+---------+------+------+-----------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+--------+---------+------+------+-----------------------+
| 1 | SIMPLE | T | range | idx_ab | idx_ab | 8 | NULL | 1003 | Using index condition |
+----+-------------+-------+-------+---------------+--------+---------+------+------+-----------------------+
1 row in set (0.00 sec)

I thought mysql can't use index after range condition.

Viewing all articles
Browse latest Browse all 1954

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>