Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


disable /enable indices? Is it worth it?


disable /enable indices? Is it worth it?

Author
Message
curious_sqldba
curious_sqldba
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1543 Visits: 3573
We are loading large number of records in table and i am trying to find the best approach.

i) Disable all indices including cluster and non-cluster.

ii) Load all the data

iii) Re-enable all indices.

I came across mixed responses online. Since we are enabling the indices anyway, why even disable them? I am guessing it will take the same amount of time to enable them back compared to have it enabled when we are loading the data. If we do not disable the index , we will need to update the stats which will also take some time.

Also, wouldn't i just need to re-enable clustered index and that should also take care of nc indices?

If there is a better way to do this please let me know.
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
If you disable the clustered index, the entire table is inaccessible (can't be read or modified), so you can't do that before a load or the load will fail.

As for disable NC indexes before and enable afterwards, maybe. There's no hard answer that works everywhere. It depends on the overhead the indexes would put on the insert and on how long it takes to rebuild them. You have to test and see what works in your situation


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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


curious_sqldba
curious_sqldba
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1543 Visits: 3573
GilaMonster (10/6/2013)
If you disable the clustered index, the entire table is inaccessible (can't be read or modified), so you can't do that before a load or the load will fail.

As for disable NC indexes before and enable afterwards, maybe. There's no hard answer that works everywhere. It depends on the overhead the indexes would put on the insert and on how long it takes to rebuild them. You have to test and see what works in your situation


what happens if i drop the clustered index and re-create the clustered index after the load? Would that speed up the process?
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
Drop the clustered index = recreate the entire table and rebuild all nonclustered indexes
Create the clustered index = recreate the entire table (again) and rebuild all nonclustered indexes (again)

Given that, what do you think?


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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


curious_sqldba
curious_sqldba
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1543 Visits: 3573
GilaMonster (10/6/2013)
Drop the clustered index = recreate the entire table and rebuild all nonclustered indexes
Create the clustered index = recreate the entire table (again) and rebuild all nonclustered indexes (again)

Given that, what do you think?


Got it, what if PK is not a clustered index, so basically PK is a non-clustered index. Can we disable PK which is nc index?thanks
Bhuvnesh
Bhuvnesh
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2924 Visits: 4076
curious_sqldba (10/6/2013)
Can we disable PK which is nc index?thanks
you cant disable PK infact you can drop the constraint and think how would you maintain the uniqueness

because

if duplicate records get inserted and it will need extra and useless attention to remove duplicacy and create PK

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47088 Visits: 44340
curious_sqldba (10/6/2013)
Can we disable PK which is nc index?thanks


Do you want to disable data integrity constraints in your table? Do you want to potentially allow bad data in and have it so that the constraints can't be recreated?


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

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


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