You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trying to add a dedupe_only mode to index cleanup, if someone wants to not trigger a bunch of unused index disable commands and just dedupe existing indexes. this makes sense for servers that aren't up for a long time, and for people who (rightfully) may not trust usage details.
Copy file name to clipboardExpand all lines: sp_IndexCleanup/README.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@ The procedure requires SQL Server 2012 (11.0) or later due to the use of FORMAT
29
29
| @min_writes | bigint | 0 | Minimum number of writes for an index to be considered used |
30
30
| @min_size_gb | decimal(10,2) | 0 | Minimum size in GB for an index to be analyzed |
31
31
| @min_rows | bigint | 0 | Minimum number of rows for a table to be analyzed |
32
+
| @dedupe_only | bit | 0 | When set to 1, only performs index deduplication but does not mark unused indexes for removal |
32
33
| @get_all_databases | bit | 0 | When set to 1, analyzes all eligible databases on the server |
33
34
| @include_databases | nvarchar(max) | NULL | Comma-separated list of databases to include (used with @get_all_databases = 1) |
34
35
| @exclude_databases | nvarchar(max) | NULL | Comma-separated list of databases to exclude (used with @get_all_databases = 1) |
@@ -50,6 +51,11 @@ EXECUTE dbo.sp_IndexCleanup
50
51
@table_name ='YourTable',
51
52
@debug =1;
52
53
54
+
-- Only perform deduplication without marking unused indexes for removal
55
+
EXECUTE dbo.sp_IndexCleanup
56
+
@database_name ='YourDatabase',
57
+
@dedupe_only =1;
58
+
53
59
-- Filter indexes by minimum usage thresholds
54
60
EXECUTE dbo.sp_IndexCleanup
55
61
@database_name ='YourDatabase',
@@ -79,6 +85,7 @@ EXECUTE dbo.sp_IndexCleanup
79
85
## Notes
80
86
81
87
- The procedure issues a warning when server uptime is less than 14 days, as index usage stats may not be representative
88
+
- When server uptime is less than 7 days, @dedupe_only mode is automatically enabled to prevent removing unused indexes with insufficient usage data
82
89
- Certain features like online index operations and compression are only available in specific SQL Server editions (Enterprise, Azure SQL DB, Managed Instance)
83
90
- It is recommended to have a recent backup before making any index changes
84
91
- The multi-database processing feature (@get_all_databases) analyzes each database sequentially for better performance and resource management
0 commit comments