I am trying to improve a speed of a SQL query. Currently the query looks like this:
select MYFIELD from MYTABLE where MYFIELD1 = "00"
Note that the table has index tag on field MYFIELD1.
The customer says that working against a table of about 150,000 record this takes up to 5 minutes.
I want to add two more conditions to the query, both on fields that have index tags. Therefore the query will look like following:
select MYFIELD from MYTABLE where MYFIELD1 = "00" and MYFIELD2 = "O"
and MYFIELD3 = "C"
I know that the table has much fewer records on the MYFIELD2 = "O" and then within those there are some small number where MYFIEL3 = "C", and then within those there are some that have MYFIELD1 = "00".
My question is, does it matter in which order I will put the WHERE expression in the above SQL Select?
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham