MySQL Forums
Forum List  »  Optimizer & Parser

Including set type in index
Posted by: Angus
Date: November 10, 2006 01:56PM

I'm trying to index a set properly, but I can't seem to get it to work with my queries. If I use an EXPLAIN like this

EXPLAIN SELECT * FROM t1 WHERE (set_col IS NULL OR FIND_IN_SET('set_datum',set_col)=0) AND a_varchar IN ('string1','string2',...,'stringn') AND (bool1=1 AND bool2=0)

and I have a unique index of set_col,a_varchar,bool1,bool2, it lists this index as a possibility, but then goes and uses another unique index that holds just a_varchar. How do I get it to use a more complete index?

Something else unexpected: the "key_len" from the EXPLAIN gives 52, but if I call

SELECT LENGTH(a_varchar) FROM t1 ORDER BY LENGTH(a_varchar) DESC

the first row returned is only 27.

Options: ReplyQuote


Subject
Views
Written By
Posted
Including set type in index
4279
November 10, 2006 01:56PM
2450
November 12, 2006 06:55PM
2275
November 13, 2006 09:36AM


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.