MySQL Forums
Forum List  »  Optimizer & Parser

select won't use index
Posted by: damage damage
Date: November 20, 2007 02:31AM

Hi,
I have written an SELECT statement which is not using an index. The naming of the tables and databases is a little complicated but I will post the original statement (may be it is a naming problem?).

mysql> use foo;
Database changed
mysql> explain select * from pfl.files LEFT JOIN pfl ON pfl.file = pfl.files.name WHERE pfl.files.name = 'bash';
+----+-------------+-------+------+---------------+------+---------+-------+---------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+-------+---------+-------------+
| 1 | SIMPLE | files | ref | name | name | 767 | const | 7 | Using where |
| 1 | SIMPLE | pfl | ALL | NULL | NULL | NULL | NULL | 8921877 | |
+----+-------------+-------+------+---------------+------+---------+-------+---------+-------------+

The naming:
- pfl is a table in database foo
- this table has a field with the name "file" which is indexed
- pfl is also a database which contains the table files
- this table has a field with the name "name" which is indexed

So, why is mysql not using the index on the field foo.pfl.file?

greez
Damage

Options: ReplyQuote


Subject
Views
Written By
Posted
select won't use index
4146
November 20, 2007 02:31AM
2379
November 20, 2007 04:00PM


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.