Explain MySQL indexes for me?

Filed under: Web/Tech | 4 Comments

Anyone want to explain MySQL indexes for me? I can’t seem to get them to work for a SELECT statement that includes OR. For example:

SELECT * FROM table_name WHERE column = 'x' OR column2 = 'y';

I’ve read in the manual others have trouble with OR too… So for now I’ve just made the queries use a single column (they switch back and forth depending on a variable).

The difference is striking, using the index on a single-column query the time is around .00015 seconds. Without an index and using OR, the query takes .3 seconds. Since I’m doing a lot of these queries, 3 a second is a deal breaker.

Any help would be appreciated. I don’t really have a mental hold on why indexes work in the first place, understanding that would probably be the key.

Read the latest posts

4 Responses to “Explain MySQL indexes for me?”

Leave a Reply