clarissa1996
Technical User
I have craeted a table with 2 columns (col1 and col2).
Then I have created 2 indexes (one for col1 and one for col2).
The following queries are very fast:
SELECT * FROM table WHERE col1='...';
SELECT * FROM table WHERE col2='...';
SELECT * FROM table WHERE col1='...' AND col2='...';
But if I replace "AND" with "OR":
SELECT * FROM table WHERE col1='...' OR col2='...';
the query is NOT fast !!
Here is my question:
If I make a query with an OR clause, indexes are not used ?
Is there a solution ?
Thanks for any help. Michelangelo
Then I have created 2 indexes (one for col1 and one for col2).
The following queries are very fast:
SELECT * FROM table WHERE col1='...';
SELECT * FROM table WHERE col2='...';
SELECT * FROM table WHERE col1='...' AND col2='...';
But if I replace "AND" with "OR":
SELECT * FROM table WHERE col1='...' OR col2='...';
the query is NOT fast !!
Here is my question:
If I make a query with an OR clause, indexes are not used ?
Is there a solution ?
Thanks for any help. Michelangelo