Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Disable|Enable Index Expand / Collapse
Author
Message
Posted Thursday, January 31, 2013 2:55 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 2,415, Visits: 3,374
Hi Experts,

I read in a post that during BCP,BULK INSERT kind of operation we can disable the index using
ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact DISABLE
and can re-enable it using
ALTER INDEX [IX_StoreContact_ContactTypeID] ON Sales.StoreContact REBUILD

My doubt is whats the difference it makes if we are rebuilding the index at the end? I mean rebuild is just like dropping and recreating index so why cant we drop and recreate instead of disable? Do we have any advantage in disabling?

Thanks IN Advance
Post #1413944
Posted Thursday, January 31, 2013 2:58 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075, Visits: 4,831
It is the same you are correct, but with disable / rebuild, you dont need to know the definition of the index to recreate it.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1413945
Posted Thursday, January 31, 2013 3:03 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks Antony for the quick reply.

Is that the only advantage?
Post #1413946
Posted Thursday, January 31, 2013 3:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, April 12, 2013 3:51 AM
Points: 5,075, Visits: 4,831
Yes, as disable drops the B-Tree of the index, but leaves the meta data in place, so the only way to get the index enabled again is rebuild, to rebuild the tree.

Drop obivously drops the tree and the meta data, so you need to know the name of the index, the columns of the index etc etc in order to re-create it.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1413948
Posted Thursday, January 31, 2013 3:13 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks alot Anthony..

Those details really helps in understanding exactly what happens..

Thanks Again
Post #1413953
Posted Thursday, January 31, 2013 3:38 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:49 PM
Points: 37,671, Visits: 29,925
Just don't try and disable the clustered index. There's a large difference there between dropping and disabling.


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1413964
Posted Thursday, January 31, 2013 6:04 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks Gail,

Can you please help me in understanding the difference? or docs or link is highly appreciated.
Post #1414052
Posted Thursday, January 31, 2013 6:10 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:49 PM
Points: 37,671, Visits: 29,925
Did you look in Books Online?

Guidelines for Disabling Indexes and Constraints

Disabling Clustered Indexes
The following additional guidelines apply to disabling clustered indexes:

The data rows of the disabled clustered index cannot be accessed except to drop or rebuild the clustered index. This means the following:


These operations will fail: SELECT, UPDATE, DELETE, INSERT, CREATE INDEX, CREATE STATISTICS, UPDATE STATISTICS (on the index), and ALTER TABLE statements that modify table columns or constraints.


These operations will succeed: CREATE VIEW, DROP VIEW, CREATE TRIGGER, DROP TRIGGER, DROP INDEX, ALTER TABLE ENABLE/DISABLE TRIGGER, TRUNCATE TABLE, and DROP TABLE.


Nonclustered indexes cannot be created while the clustered index is disabled.


Existing nonclustered indexes and XML indexes associated with the table are automatically disabled and cannot be accessed.


All clustered and nonclustered indexes on views that reference the table are disabled. These indexes must be rebuilt just as those on the referenced table.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1414057
Posted Thursday, January 31, 2013 7:45 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:03 AM
Points: 2,415, Visits: 3,374
Thanks a lot Gail.

Seems like disable is pretty dangerous than drop & recreate.
Post #1414148
Posted Thursday, January 31, 2013 8:53 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 5:49 PM
Points: 37,671, Visits: 29,925
No, not at all.

Just like you wouldn't randomly drop the clustered index (unless you want your table inaccessible for a while and your log to bloat), you wouldn't randomly disable the clustered index.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1414183
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse