I have trouble figuring out how the indices are used when making a query that uses OR-operator.

If I have the following table:

create table testing(
id int unsigned not null primary key auto_increment,
idx1 int unsigned not null,
idx2 int unsigned not null,
index(idx1),
index(idx2));

In this query i expect mySQL to use one of the two indices to speed up the query, but It doesn't.. :(
select * from testing where idx1=0 or idx2=1;


The thing I'm thinking about instead is the following query:
select * from testing where idx1=0
UNION
select * from testing where idx2=1;

It looks like this does speed up the query, but is this the way to go???
Is this a weaknes in mySQL or have I forgotten something?

_________________________________________________________________
Hitta rätt på nätet med MSN Sök http://search.msn.se/


--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



Reply via email to