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 2008
»
T-SQL (SS2K8)
»
Help On Execution Plan Status
Help On Execution Plan Status
Rate Topic
Display Mode
Topic Options
Author
Message
Shadab Shah
Shadab Shah
Posted Friday, November 30, 2012 7:52 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 2:11 PM
Points: 169,
Visits: 355
Hi All,
I am a newbie in SQL Server and like exploring it. Currently i was working with some complex queries and happen to see there Execution Plan. I saw that there were some Clustered index which were 'ClusteredIndexSeek' and Some Clustered Index as 'ClusteredIndexScan'.
So my basic question is, how does the query analyzer decide when to used ClusteredIndexScan and when to used ClusteredIndexSeek.
Post #1391318
Dennis Post
Dennis Post
Posted Friday, November 30, 2012 8:04 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Today @ 6:48 AM
Points: 109,
Visits: 305
Paul White's blog series will pretty much any question you could ever think of on this.
http://www.sqlservercentral.com/articles/SQL+Server+2008/71019/
For better, quicker answers on T-SQL questions, read Jeff Moden's suggestions.
http://www.sqlservercentral.com/articles/Best+Practices/61537/
"Million-to-one chances crop up nine times out of ten." ― Terry Pratchett, Mort
Post #1391333
GilaMonster
GilaMonster
Posted Friday, November 30, 2012 8:12 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 38,096,
Visits: 30,390
Seek when there's a SARGable predicate (<column> <comparison operator> <expression>) on the index key columns. Scan if there isn't. Very, very simplified, but that's the basics.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1391351
Grant Fritchey
Grant Fritchey
Posted Friday, November 30, 2012 9:22 AM
SSChampion
Group: General Forum Members
Last Login: Yesterday @ 9:49 AM
Points: 13,436,
Visits: 25,281
And the indexes have to be selective enough to be useful for a seek or you'll get scans. Same things apply to non-clustered indexes too.
For lots more detail on query tuning and execution plans, take a look at my books (listed below).
----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans
Product Evangelist for
Red Gate Software
Post #1391418
ScottPletcher
ScottPletcher
Posted Friday, November 30, 2012 12:28 PM
Ten Centuries
Group: General Forum Members
Last Login: 2 days ago @ 10:11 AM
Points: 1,333,
Visits: 1,803
Grant Fritchey (11/30/2012)
And the indexes have to be selective enough to be useful for a seek or you'll get scans. Same things apply to non-clustered indexes too.
For lots more detail on query tuning and execution plans, take a look at my books (listed below).
Not for clustered indexes. SQL can do a seek on a clustered index even if you're SELECTing 99% of the rows.
SQL DBA,SQL Server MVP('07, '08, '09)
One man with courage makes a majority. Andrew Jackson
Post #1391499
GilaMonster
GilaMonster
Posted Friday, November 30, 2012 12:49 PM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 3:13 PM
Points: 38,096,
Visits: 30,390
ScottPletcher (11/30/2012)
Grant Fritchey (11/30/2012)
And the indexes have to be selective enough to be useful for a seek or you'll get scans. Same things apply to non-clustered indexes too.
For lots more detail on query tuning and execution plans, take a look at my books (listed below).
Not for clustered indexes. SQL can do a seek on a clustered index even if you're SELECTing 99% of the rows.
More correctly, not for any index that covers the query. A covering nonclustered index can and will be used for a seek up to 100% of the rows.
Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild
: Discussions on DB performance with occasional diversions into recoverability
We walk in the dark places no others will enter
We stand on the bridge and no one may pass
Post #1391515
Paul White
Paul White
Posted Saturday, December 01, 2012 10:38 PM
SSChampion
Group: General Forum Members
Last Login: Today @ 10:48 AM
Points: 10,990,
Visits: 10,578
Shadab Shah (11/30/2012)
So my basic question is, how does the query analyzer decide when to used ClusteredIndexScan and when to used ClusteredIndexSeek.
It will often consider both alternatives. It estimates the cost of each and chooses the one that appears cheapest (according to the model it uses). There are a number of detailed factors that affect the cost calculation, and overall plan selection, but that's a basic answer to your basic question.
Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1391700
« 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.