| Bug #4113 | Optimizer cannot figure out how to use a PRIMARY in a HEAP table | ||
|---|---|---|---|
| Submitted: | 11 Jun 2004 20:47 | Modified: | 12 Jun 2004 6:18 |
| Reporter: | Dathan Pattishall | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: MyISAM storage engine | Severity: | S1 (Critical) |
| Version: | 4.0.18 | OS: | Linux (Linux dbuser1.gbxsc.friendster.c) |
| Assigned to: | CPU Architecture: | Any | |
[11 Jun 2004 20:47]
Dathan Pattishall
[11 Jun 2004 20:52]
Dathan Pattishall
BTW this problem does not effect a MYISAM or INNODB version of the same table.
[11 Jun 2004 20:53]
Peter Zaitsev
This is not a bug. In MySQL 4.0.x HEAP table have only HASH indexes supported which are only helpful with full match. No prefix or range match may use indexes. In your case you can just add extra index on the first keypart.
[11 Jun 2004 20:56]
Dathan Pattishall
if I add a key to the table ALTER TABLE potentialfriends add index (originator); SELECT * FROM Query OK, 5472562 rows affected (25.53 sec) Records: 5472562 Duplicates: 0 Warnings: 0 xplain SELECT * FROM potentialfriends where originator=101; +------------------+------+--------------------+------------+---------+-------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +------------------+------+--------------------+------------+---------+-------+------+-------------+ | potentialfriends | ref | PRIMARY,originator | originator | 4 | const | 10 | Using where | +------------------+------+--------------------+------------+---------+-------+------+-------------+ it works, but this sucks if I had to do this.
[12 Jun 2004 6:18]
Sergei Golubchik
another possibility is, of course, to upgrade to 4.1 - where HEAP tables support binary tree indexes - and thus can do prefix searches
