My problem is how do I maintain an index on table, weekly we are deleting and inserting bulk amount of data from the table.Because drop and create index taking too long time..
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
You could set up a job to rebuild or reorganize them weekly/daily.
I recommend checking out http://sqlfool.com/2011/06/index-defrag-script-v4-1/
This index rebuilder is highly customizable.
What you want to do is have an ongoing analysis of the fragmentation of the indexes pertaining to your particular table. The below query will show you average fragmentation per index for all indexes in your particular object that have a
You can work this into a logical script that is run on a schedule depending on your environment and how big of a maintenance window you have. A good rule of thumb is that fragmentation of 5% to 30% warrants an index reorganization, and 30% or greater should be rebuilt.
Edit: I've worked in simple
Also check out Ola Hallengren's excellent database maintanence script at http://ola.hallengren.com/
You can customize it to ignore backups & integrity checks if you dont need them.