September 2, 2008 at 1:06 am
Hi Guys
I have a table of twenty columns like :
ServiceDescID bigint Primary Key,
JDOclassX varchar(255)
.
.
.
) The table has 3206831 rows. the column JDOClassx has only 2 distinct rows. I have created a nonclusterd index on this column.But when I issue a simple query "Select distinct jdoclassx from tablename".The Estimated execution plan show me Index Scan.What should i do.
Thanx in advance.
September 2, 2008 at 2:00 am
If you're asking for all the values in the table to be read (as you are) the only way that SQL can possible do that is to scan the index. There's not filter condition in that query that can be used for a seek.
Consider if someone asked you to find all the different surnames in the telephone book. Even though the book's sorted by surname (like an index), you'd have to read the entire list to get the unique values.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply