1

We have a clustered index in table Tbl with order of A,B,C. Does it make senses to write a query to have

WHERE A = @a, B = @b, C = @c

or it'll be as same as

WHERE C = @c, B = @b, A = @a

Does the order of query make sense for clustered index?

1
  • 1
    And you have to use AND, not commas, between the conditions in WHERE. Commented Aug 7, 2014 at 8:55

2 Answers 2

6

It makes no difference: the optimiser evaluates the query and will work out predicate order for itself, matching a suitable index and all the other good stuff it does.

This is because SQL is "declarative" not "procedural": you say what you want, not how to do it.

It's nicer to read though...

-3

Actually when we use the where clase then sql creates seperate pages for each where clause. then its make join based on AND , OR and then produce the output. So, here switching the where clause is not a matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.