SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Dropping indexes


Dropping indexes

Author
Message
Catcha
Catcha
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 169
Hi All,

I need to drop indexes on a table over 500mil records, I wandering is it better to drop the indexes the following sequence

non-clustered indexes -> primary -> clustered index

or the following

Clustered index -> primary -> non-clustered indexes

I would assume the first one will be slower?

Is my assumption correct?
sainatth.wagh
sainatth.wagh
Grasshopper
Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)Grasshopper (20 reputation)

Group: General Forum Members
Points: 20 Visits: 68
Yes. The first one will be slower compared to second since the first one will be doing FTS....I mean Full Table Scan and then based on the inetrnal ordering will delete the indexes.
Suresh B.
Suresh B.
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5230 Visits: 5330
How many indexes are there in the table?
Why do you want to delete all the indexes?
Why do you want to delete the primary key as well?

I believe second one would be slower as dropping the CI would rebuild the NC indexes.
Catcha
Catcha
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 169
4 non-clustered, 1 clustered and 1 primary key.

For bulk insert.
rhythmk
rhythmk
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1774 Visits: 1099
Catcha (9/13/2012)
4 non-clustered, 1 clustered and 1 primary key.

For bulk insert.



But do you think that dropping the index will save your time ?
Because as you mentioned that the table contains millions of records, so I guess to rebuild the indexes will be time taking.

--rhythmk
------------------------------------------------------------------
To post your question use below link

http://www.sqlservercentral.com/articles/Best+Practices/61537/
:-)
Catcha
Catcha
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 169
Yes, with recreating the index I will use the following order

Non-clustered -> primary key -> clustered

So rebuilding of whole table will be performed last.

Thought?
rhythmk
rhythmk
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1774 Visits: 1099
Catcha (9/14/2012)
Yes, with recreating the index I will use the following order

Non-clustered -> primary key -> clustered

So rebuilding of whole table will be performed last.

Thought?




Again I would like to know that how many records you are going to insert.As in case the number records are very less than the existing records comparatively, it is recmmonded not to drop the indexes.

Note - The records(500 millions) as you mentioned in your table will break your head during index rebuild.So better to give it a try on development or test environment instead of doing on production.

--rhythmk
------------------------------------------------------------------
To post your question use below link

http://www.sqlservercentral.com/articles/Best+Practices/61537/
:-)
Grant Fritchey
Grant Fritchey
SSC Guru
SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)SSC Guru (101K reputation)

Group: General Forum Members
Points: 101699 Visits: 33014
Catcha (9/14/2012)
Yes, with recreating the index I will use the following order

Non-clustered -> primary key -> clustered

So rebuilding of whole table will be performed last.

Thought?




Nope. Backwards. If you create the clustered index last, it will recreate all the other indexes. Recreating, clustered first, then everything else.

----------------------------------------------------
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 Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Catcha
Catcha
SSC Veteran
SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)SSC Veteran (216 reputation)

Group: General Forum Members
Points: 216 Visits: 169
Yes, that makes sense.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search