List:General Discussion« Previous MessageNext Message »
From:Thilo Salmon Date:April 16 1999 3:25pm
Subject:How do I force the use of indices within select queries?
View as plain text  
Hi,

I'm trying to optimize a simple select query on a single table w/ roughly
2 million rows and 10 columns. It looks like:

SELECT * FROM table where (a = '1' or a= '2') and (b = '1' or b='2') and c
= '3'

a, b and c are indexed. However, when I use explain to find out which
index is used, it turns out that c's is used. Since there are only two
possible values for c, I would very much prefer to force MySQL to use
either a or b's index. Is there a way to do this? Can't MySQL use
indices for fields that occur at multiple times within s single
whereclause? Can MySQL even use multiindices for this query? I didn't find
anything in the docs, but perhaps I'm lacking some basic understanding of
SQL. How would you go about improving the performance for this query? I'm
looking into 10-20 queries a second on a Intel/Linux box. 

Ciao
  Thilo


Thread
Can Ignore some Database to write update logwuym15 Apr
  • Can Ignore some Database to write update logMichael Widenius16 Apr
  • Re: Can Ignore some Database to write update logwuym16 Apr
    • Re: Can Ignore some Database to write update logStephan Greene16 Apr
      • How do I force the use of indices within select queries?Thilo Salmon16 Apr