x

Index creation time

I have a table with non-clustered index e.g. Index1 on Column1, Column2 & Column3

Now i want to create a clustered index2 on column1.

Index creation time point of view, does it make any difference if the column is being used by other index?

more ▼

asked Feb 22, 2010 at 11:03 AM in Default

kardile gravatar image

kardile
301 14 14 14

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

In direct answer to your question, no.

But creating a clustered index will physically order the data on the disk, so will take more time than creating a non-clustered index.

more ▼

answered Feb 22, 2010 at 11:37 AM

Matt Whitfield gravatar image

Matt Whitfield ♦♦
29.5k 61 65 87

Matt, given that the 2nd index is created is there any difference between 1 - if the 1st index is on col2 with col1 and col3 included and 2 - if the 1st index is over all 3 columns? Just curious!
Feb 22, 2010 at 12:37 PM Fatherjack ♦♦
Not really, no. There would be a difference if you clustered on more columns because when converting from a heap to a clustered index the non-clustered index would change such that it would go from pointing to RIDs to storing the clustered index values (so more columns = more space = more work). But I can't see any reason that the time would differ based on what was present in the non-clustered index. I'm sure I'll learn that I'm wrong a couple of years down the line though!! :)
Feb 22, 2010 at 12:44 PM Matt Whitfield ♦♦
Matt, its a good answer and true, but I think simply saying the clustered index physically orders the data hides a lot of very important nuance. Itzik Ben Gan has an article with a lot of the details and nuances at http://www.sqlmag.com/Article/ArticleID/92886/sql_server_92886.html
Feb 22, 2010 at 02:30 PM TimothyAWiseman
(comments are locked)
10|1200 characters needed characters left

Based on your first index; Column1, Column2, Column3, I'd consider the second index on Column1 to be redundent. Of cousre, there is always that "It Depends" when it comes to any development.

more ▼

answered Feb 24, 2010 at 03:25 PM

Lynn Pettis gravatar image

Lynn Pettis
275 3

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x131

asked: Feb 22, 2010 at 11:03 AM

Seen: 1484 times

Last Updated: Feb 22, 2010 at 11:03 AM