﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Why no Index Scan? / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 20 Jun 2013 00:17:50 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Why no Index Scan?</title><link>http://www.sqlservercentral.com/Forums/Topic1404131-392-1.aspx</link><description>Will digest.Thanks Gail</description><pubDate>Tue, 08 Jan 2013 05:10:03 GMT</pubDate><dc:creator>diamondgm</dc:creator></item><item><title>RE: Why no Index Scan?</title><link>http://www.sqlservercentral.com/Forums/Topic1404131-392-1.aspx</link><description>There's actually no difference in this case because of the inequality[url]http://sqlinthewild.co.za/index.php/2009/02/06/index-columns-selectivity-and-inequality-predicates/[/url]</description><pubDate>Tue, 08 Jan 2013 05:06:31 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Why no Index Scan?</title><link>http://www.sqlservercentral.com/Forums/Topic1404131-392-1.aspx</link><description>[quote][b]GilaMonster (1/8/2013)[/b][hr]It's a seek because you have a SARGable predicate (Col1 &amp;gt; 60 ) on a column that is the leading column of the index.Scan is when you have nothing to seek on and SQL has to read the entire index or table. In this case, there is something to seek on.[/quote]Thanks for your response Gail :)I think where we are stuck is;At the leaf level of the NCI(no include), Col2 is sorted and the evaluation of whether or not the value meets the predicate could be/should be optimised?In the case of the INCLUDE; for Col1 = 61, Col2 = {random order}In the case of the 'COVER'; for Col1 = 61, Col2 = {ordered numbers}Perhaps we lack a fundamental understanding of what's going on.</description><pubDate>Tue, 08 Jan 2013 04:40:51 GMT</pubDate><dc:creator>diamondgm</dc:creator></item><item><title>RE: Why no Index Scan?</title><link>http://www.sqlservercentral.com/Forums/Topic1404131-392-1.aspx</link><description>It's a seek because you have a SARGable predicate (Col1 &amp;gt; 60 ) on a column that is the leading column of the index.Scan is when you have nothing to seek on and SQL has to read the entire index or table. In this case, there is something to seek on.</description><pubDate>Tue, 08 Jan 2013 04:22:08 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>Why no Index Scan?</title><link>http://www.sqlservercentral.com/Forums/Topic1404131-392-1.aspx</link><description>Hi All!Hoping someone can help us understand this.Given;[code="sql"]USE tempdbGOIF OBJECT_ID('tempdb.dbo.Covered') IS NOT NULL DROP TABLE CoveredIF OBJECT_ID('tempdb.dbo.Included') IS NOT NULL DROP TABLE IncludedSET NOCOUNT ON;CREATE TABLE Covered(	 RowID	INT IDENTITY(1,1)	,Col1	INT NOT NULL	,Col2	INT NOT NULL)CREATE TABLE Included(	 RowID	INT IDENTITY(1,1)	,Col1	INT NOT NULL	,Col2	INT NOT NULL)GOINSERT INTO CoveredSELECT TOP 100000 		 ABS(CHECKSUM(NEWID()) % 100)		,ABS(CHECKSUM(NEWID()) % 10000)FROM sys.syscolumns T1, sys.syscolumns T2, sys.syscolumns T3GO 10INSERT INTO IncludedSELECT TOP 100000		 ABS(CHECKSUM(NEWID()) % 100)		,ABS(CHECKSUM(NEWID()) % 10000)FROM sys.syscolumns T1, sys.syscolumns T2, sys.syscolumns T3GO 10CREATE INDEX c_Covered	ON Covered (RowID)CREATE INDEX c_Included	ON Included (RowID)CREATE INDEX nc_Covered		ON Covered (Col1, Col2)CREATE INDEX nc_Included	ON Included (Col1) INCLUDE (Col2)[/code]And queries;[code="sql"]SELECT COUNT(*)FROM CoveredWHERE Col1 &amp;gt; 60 AND Col2 &amp;gt; 9998SELECT COUNT(*)FROM IncludedWHERE Col1 &amp;gt; 60 AND Col2 &amp;gt; 9998[/code]We were expecting the second query to perform an Index Scan because included column (Col2) is not sorted.Is it regarded as a Scan only when multiple levels of the B-Tree are traversed?...the non clustered index (Col1) would get us to the leaf level and then find qualifying values for Col2 (unsorted).Please let me know if my question is not clear.Thanking you in advance.</description><pubDate>Tue, 08 Jan 2013 04:17:38 GMT</pubDate><dc:creator>diamondgm</dc:creator></item></channel></rss>