MySQL Forums
Forum List  »  Optimizer & Parser

Re: Index evaluation
Posted by: Drei Bit
Date: July 23, 2007 05:18PM

It gets stranger:

explain select id from t2 use index (ix_txt_id) where txt like 'Hall%';

/*
+----+-------------+-------+-------+---------------+-----------+---------+------+------+-------------+
| id | select_type | table | type  | possible_keys | key       | key_len | ref  | rows | Extra       |
+----+-------------+-------+-------+---------------+-----------+---------+------+------+-------------+
|  1 | SIMPLE      | t2    | range | ix_txt_id     | ix_txt_id | 768     | NULL |   80 | Using where |
+----+-------------+-------+-------+---------------+-----------+---------+------+------+-------------+
*/

explain select id from t2;
/*
+----+-------------+-------+-------+---------------+-------+---------+------+--------+-------------+
| id | select_type | table | type  | possible_keys | key   | key_len | ref  | rows   | Extra       |
+----+-------------+-------+-------+---------------+-------+---------+------+--------+-------------+
|  1 | SIMPLE      | t2    | index | NULL          | ix_id | 4       | NULL | 400000 | Using index |
+----+-------------+-------+-------+---------------+-------+---------+------+--------+-------------+
*/

Why is the optimizer reluctant to use the Index only? At least with range queries it seems. Or is he just hiding it?

Cheers
3bit

Options: ReplyQuote


Subject
Views
Written By
Posted
3301
July 23, 2007 04:51PM
Re: Index evaluation
2282
July 23, 2007 05:18PM
2240
July 24, 2007 02:06AM
2239
July 24, 2007 04:33AM
2266
July 23, 2007 07:27PM
2222
July 24, 2007 05:24AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.