Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL and Index

Status
Not open for further replies.

clarissa1996

Technical User
Jan 31, 2002
78
CH
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top