February 8, 2008 at 8:09 am
I have a query
Select * from Table1 where
Filter1>100 and Filter2= "test" and filter3< 100
Can anyone tell me how would this query executed?
Will Filter1 will be filtered first or filter 3? Reason i want to know is because if filter1 is getting executed first then
i would put that filter which would reduce more number of records.
Same question i have for "OR" condition
Select * from Table1 where
Filter1>100 or Filter2= "test" or filter3< 100
Thanks,
Ramesh.
February 8, 2008 at 8:16 am
You can view the execution plan in SSMS for the query and see the order in which things are applied. The short answer is "it depends". The optimizer will consider # of records, based on statistics, and indexes and it could do either one first.
The way you write it is irrelevant.
February 8, 2008 at 12:00 pm
Hi,
the order of the where condtions doesn't play interms which one to execute first. It depends on the columns which you are using in where condition has indexes or not.
Thanks -- Vj
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply