Environment: SQL Server 2008 R2 Enterprise Edition and using primary filegroup only
Don't have enough space to create a new filegroup and move all tables/indexes to the new filegroup.
Objective: Reclaim unused space to OS
I have deleted multiple rows in the table HISTORY which has clustered index (the primary key) in database TEST since years of data were stored in that table and now there is 14 GB free space. The table HISTORY has a column which is text datatype. The size of the table should not grow too much since only 6 months of data should be kept.
I plan to do the followings:
- DBCC SHRINKFILE (TEST1, 30000); -- Does it make a big difference by specifying target size? If setting the target size closer to the current size, will dbcc shrinkfile finish in less time?
- ALTER INDEX ALL ON TEST.HISTORY REBUILD WITH (ONLINE = ON) or ALTER INDEX ALL ON TEST.HISTORY REORGANIZE WITH (ONLINE = ON)
Does #2 ALTER INDEX require GB of space? If yes, how to estimate?
I'm going to delete the same table in another database PRODUCTION. Should I delete the rows in multiple batches and repeat #1 and #2 in each batch?