I removed some rows from a very large table. Then I ran a query that usually runs within a few seconds and found it to be running开发者_JS百科 very slowly after deleting the rows. I re-built my index and ran my query and found it to be fast again. Could deleting those rows caused the index to be fragmented?
Yes, deleting rows affects the index and maintenance should take place to keep the index relatively in sync with existing data.
Rebuilding an index was likely unnecessary - you only need to do this if the physical fragmentation is 30 percent or more according to MS documentation. REORGANIZE
is usually a better choice - think of it as defraging the index.
This is a good article series on SQL Server Index Fragmentation.
精彩评论