Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
T-SQL (SS2K5)
»
order of SQL execution
order of SQL execution
Rate Topic
Display Mode
Topic Options
Author
Message
Ramesh Lende
Ramesh Lende
Posted Friday, February 08, 2008 8:09 AM
Valued Member
Group: General Forum Members
Last Login: Friday, June 03, 2011 9:11 AM
Points: 64,
Visits: 104
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.
Post #453261
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Friday, February 08, 2008 8:16 AM
SSC-Dedicated
Group: Administrators
Last Login: Yesterday @ 2:54 PM
Points: 31,410,
Visits: 13,726
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.
Follow me on Twitter:
@way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
Post #453268
Vijaya Kadiyala
Vijaya Kadiyala
Posted Friday, February 08, 2008 12:00 PM
SSCommitted
Group: General Forum Members
Last Login: Monday, October 25, 2010 6:09 AM
Points: 1,621,
Visits: 409
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
http://dotnetvj.blogspot.com
Thanks -- Vijaya Kadiyala
www.dotnetvj.com
SQL Server Articles For Beginers
Post #453403
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.