I am new to index maintenance. I see that most of our indexes are modified using create index with drop_existing = on. For example:
create nonclustered index ixn_SomeTable__SomeIndexName_ic1
on dbo.SomeTable ( Column1 )
include ( Column2, IncludeThisNewColumn3 )
with ( sort_in_tempdb = on, drop_existing = on, online = on, fillfactor = 95 ) on [SomeFileGroup]
go
but I see TSQL also has alter index statement.
Questions:
- What does the
drop_existing=ondo? Does it just drop the index if it exists and recreates it, or does it save on rebuilding the index (re-indexing data etc.) if the modifications don't really need rebuilding of index (for example, including a column in a non-clustered index)? - What is the difference between
create indexwithdrop_existing = onandalter index? When do I absolutely have to use one or the other? - Does the index become unavailable when the modifications to the index are in progress, and is there a way to keep the unavailable time to a minimum?