top | item 37607396

(no title)

jletienne | 2 years ago

just for clarity ordering your where clauses can matter right? I've tested it and it made a difference, i'm not hallucinating right

discuss

order

aidos|2 years ago

You’re probably hallucinating!

A good planner is going to pick the best strategy however you order them, because it’s job is to give the results fastest no matter how you write the query (all things being equal).

Consider that there’s a unique index on one of the 2 columns. It’s almost certainly optimal to use that to find a single row and then execute your other filters no matter the order.

Maybe there’s a situation where you can adjust the filters so ones that remove the most rows with the least cpu cycles are first? I’m going to try to create an example to see if I can make it behave differently.

whoiscroberts|2 years ago

Indeed it can, at least with sqlserver.