Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2004, 01:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:Originally posted by mehdi62b
 Jeff,I have a question?
if we change the clustered index of primary column(to nonclustered index)so we
could make this column (TD_Exp_Status) as clustered,
whether query processor considers our column to be sorted
correctly regardless of other alternatives?

--------------------------------------------
Mehdi.:)
I'm not sure I can correctly parse your question.

The query processor is aware of the fact that the clustered index orders the data rows. This is why a clustered index is nice to use for range queries: the processor knows that the data is in order by the index column and can simply scan rows sequentially for the range it is searching for, and then, the rest of the data is just "there".

The processor also knows that indexes (clustered or not) order the data according to the index key and will attempt to use this information when trying to satisfy an ORDER BY clause. Just remember that other operations (like JOINs) may mean this is not possible and a sort will have to be done regardless of the indexes available.

A requirement of the clustered index is that each row can be uniquely identified. This is because other indexes contain the clustered index key and use that to obtain the data row. So, if you use a column which is not unique, the system will add a hidden "unique-ifier" to the clustered index key. This extra overhead is carried along in all the other indexes on the table.

Because of this, I don't think it is a good idea to use a non-unique key as the clustered index key. I also don't think any benefit is obtained by placing an index on a column value which has a small range of distinct values. If the index is on a column is not very specific, the query processor is aware of this, and may very well decide the index isn't worth the bother, since it will have to scan all the duplicates the index entry refers to.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old August 22nd, 2004, 01:54 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hmmm,Thank you for the reply.

--------------------------------------------
Mehdi.:)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Index on View - SQL prince500 SQL Server 2005 5 September 7th, 2011 07:35 AM
index by table in pl/sql vipin1982 All Other Wrox Books 1 October 1st, 2008 12:19 PM
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
Urgent help! Index Server Query returns 0 records rakeshsharma Internet Information Services 0 August 29th, 2006 12:35 AM
Problem with Index server Query MurthyGarimella VS.NET 2002/2003 0 July 7th, 2004 06:57 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.