Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to drop an index very fast

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-25 : 02:58:32
Dear All,
is there any way to drop an index very fast?...here it is taking much time with the general drop index statement

Arnav
Even you learn 1%, Learn it with 100% confidence.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-25 : 03:06:47
there's an option called online on which when used tables will be available to queries while dropping the index.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-25 : 03:09:28
i think that is only for clustered indexes...
can you please give me the syntax for dropping the non clustered index fastly with online option....

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2008-11-25 : 03:15:10
drop index index_name on table_name

Arnav
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

darkdusky
Aged Yak Warrior

591 Posts

Posted - 2008-12-02 : 11:07:32
Is index clustered or non-clustered? The online option is only available for clustered.

drop index index_name on table_name
WITH (ONLINE = ON)

You may also speed up dropping clustered index by moving index to new filegroup on different disk.
It would also help with performance of table generally.

You can incorporate drop and move to new disk in same command, using MOVE.
eg.
--Create FileGroup
ALTER DATABASE db
ADD FILEGROUP NewGroup;
EXECUTE ('ALTER DATABASE db
ADD FILE (NAME = File1,
FILENAME = 'E:\test\File1.ndf'')
TO FILEGROUP NewGroup')
--drop index and move to new filegroup
DROP index index_name on table_name
WITH (ONLINE = ON, MOVE TO NewGroup)
Go to Top of Page
   

- Advertisement -