Bug #5138 | INDEX CHOISE ON OPTIMIZER | ||
---|---|---|---|
Submitted: | 21 Aug 2004 21:46 | Modified: | 16 Nov 2004 22:36 |
Reporter: | Roberto Spadim (Basic Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.1.3 maybe others | OS: | Linux (Linux maybe others) |
Assigned to: | Sergey Petrunya | CPU Architecture: | Any |
[21 Aug 2004 21:46]
Roberto Spadim
[23 Aug 2004 3:44]
Matthew Lord
I verified this on linux (2.4.21 #12 SMP) and windows 2000 SMP. A heap index should almost always be used when searching for a constant string as I am in this example unless maybe we're also ordering by the column and there are many matches. drop table if exists heaptest; create table heaptest (id int unsigned not null primary key auto_increment, name varchar(20) not null ) type=heap; insert into heaptest (name) values ('Matt'), ('Lilu'), ('Corbin'), ('Carly'), ('Suzy'), ('Hoppy'), ('Burrito'), ('Mimi'), ('Sherry'), ('Ben'), ('Phil'), ('Emily'), ('Mike'); alter table heaptest add index heap_idx (name); alter table heaptest add index btree_idx using btree (name); explain select * from heaptest where name='matt'\G
[7 Sep 2004 22:01]
Sergey Petrunya
ChangeSet@1.1994, 2004-09-08 02:07:53+04:00, sergefp@mysql.com
[16 Nov 2004 22:36]
Sergey Petrunya
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html