Groups | Blog | Home
all groups > sql server (microsoft) > march 2005 >

sql server (microsoft) : Where clause arguments


Bob
3/18/2005 5:48:24 AM
Hello folks!

Is it true that query performance will be enhanced if you place the
arguments in your where clause in a position such that the "most
prevalent" filters are towards the left?

So if I wanted to query a table that had fields for Gender and Color
and Pants and I wanted to see people who wear red pants the where
cluase would be

Where Gender='M' and Color='Red'

INSTEAD OF

Where color ='Red' and Gender='M'

So that the argument that removes the most records goes first.
Obviously, index and other criteria come into play as well.
Madhivanan
3/26/2005 1:10:39 AM

I think the performace will not be affected if you place arguments in
different order. Check it with query analyser by setting show execution
plan

Madhivanan
jcelko212 NO[at]SPAM earthlink.net
3/28/2005 6:00:08 PM
[quoted text, click to view]
arguments in your where clause in a position such that the "most
prevalent" filters are towards the left? <<

No. And stepping on a bug does not cause rain.
Greg D. Moore (Strider)
4/8/2005 12:00:00 AM

[quoted text, click to view]

This was a holdover from the 6.5 optimizer days I believe. But has not been
true since then.


[quoted text, click to view]

AddThis Social Bookmark Button