MySQL Forums
Forum List  »  Performance

Are seperate indexes needed for lower-comparisons?
Posted by: Clemens Eisserer
Date: September 04, 2007 06:54AM

Hello,

I would like to do case-insensitive comparisons so I use LOWER:
SELECT name FROM album WHERE LOWER(name) LIKE LOWER('a%') ORDER BY name LIMIT 100;

I have an index on name, unlike postgres mysql does not allow the lower-function specified at index-creation.

Explain gives me the following output:
mysql> explain SELECT name FROM lieferant WHERE LOWER(name) LIKE LOWER('a%') ORDER BY name LIMIT 100;
+----+-------------+-----------+-------+---------------+------------+---------+------+------+--------------------------+
| id | select_type | table     | type  | possible_keys | key        | key_len | ref  | rows | Extra                    |
+----+-------------+-----------+-------+---------------+------------+---------+------+------+--------------------------+
|  1 | SIMPLE      | album | index | NULL          | test_index | 258     | NULL | 1053 | Using where; Using index |
+----+-------------+-----------+-------+---------------+------------+---------+------+------+--------------------------+
1 row in set (0.00 sec)

Do I need to change/optimize something to make this query as fast as possible?
Its used for auto-completition, and although the completition is done asynchrous it would be great if it could run quick.
Does this mean the index is used, is there anything I could do better for this query?

Thank you in advance, lg Clemens

Options: ReplyQuote


Subject
Views
Written By
Posted
Are seperate indexes needed for lower-comparisons?
2548
September 04, 2007 06:54AM


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.