MySQL Forums
Forum List  »  Newbie

How to create/choose a suitable index
Posted by: Tim Streater
Date: August 05, 2005 10:11AM

I am having trouble figuring out a suitable index(es) in the following case:

select * from circuit where (col1a=val1 and col2a=val2) or (col1b=val1 and col2b=val2);

(it happens that I use val1 and val2 as above).

Every choice I make for index doesn't, according to EXPLAIN, get used by the SELECT. The table has a few thousand entries and I expect the SELECT to return one or two at most. Well, it does, but quite slowly (in fact the SELECT is a bit more complex) and I would really like to improve this particular combination as its at the inner-most loop of my PHP code :-)

INDEXes seem to work for ANDs but not when there's an OR in the month (sorry). So an index of columns A,B gets used if you have A AND B in the WHERE but not A OR B.

I can't find any suitable pointers in the docs, so any clues would be appreciated.

Thanks -- tim

Options: ReplyQuote


Subject
Written By
Posted
How to create/choose a suitable index
August 05, 2005 10:11AM


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.