I want to test the rebuild and reorganize operations for the indexes in sql server and for that I need to populate the db with test data that generates high fragmentation levels/percentages. Does anyone have a hint for me on how to do this? I heard about backwards insert, does this hep? If yes, how can I achieve this?
Many thanks!
Sql-server – test data to generate high index fragmentation level
fragmentationindexsql server
Related Question
- Sql-server – REORGANIZE seems to work as well as REBUILD all the time
- Sql-server – Heap having high fragmentation
- Sql-server – Does index rebuild time depend on the fragmentation level
- Sql-server – Manually create index fragmentation
- Sql-server – Rebuild index in SQL Server does not reduce fragmentation
- Sql-server – Index fragmentation increased significantly after rebuild
- Sql-server – Index fragmentation problem after disabling page-level locking for an Index
- Sql-server – How big of a table or how many data pages in an index is worth considering running index rebuild or index reorganize operations on
Best Answer
You can use Paul Randal's script or similar to it.
The idea here is to create two similar table (of the same size) with clustered PK on identity (or other ever increasing key), then to drop the first created table and to
SHRINK database
.Since
SHRINK
takes the pages from the end of data file and moves them to file beginning your second clustered index will be "inverted" and will be perfectly fragmented as the physical order now will be perfectly inverse to its logical order.Why you should not shrink your data files