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
| @database_name | sysname | NULL | The name of the database you wish to analyze |
26
-
| @schema_name | sysname | NULL | The schema name to filter indexes by |
26
+
| @schema_name | sysname | NULL | The schema name to filter indexes by - limits analysis to tables in the specified schema |
27
27
| @table_name | sysname | NULL | The table name to filter indexes by |
28
28
| @min_reads | bigint | 0 | Minimum number of reads for an index to be considered used |
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,16 @@ 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
+
59
+
-- Analyze tables in a specific schema only
60
+
EXECUTE dbo.sp_IndexCleanup
61
+
@database_name ='YourDatabase',
62
+
@schema_name ='YourSchema';
63
+
53
64
-- Filter indexes by minimum usage thresholds
54
65
EXECUTE dbo.sp_IndexCleanup
55
66
@database_name ='YourDatabase',
@@ -79,6 +90,7 @@ EXECUTE dbo.sp_IndexCleanup
79
90
## Notes
80
91
81
92
- The procedure issues a warning when server uptime is less than 14 days, as index usage stats may not be representative
93
+
- When server uptime is less than 7 days, @dedupe_only mode is automatically enabled to prevent removing unused indexes with insufficient usage data
82
94
- Certain features like online index operations and compression are only available in specific SQL Server editions (Enterprise, Azure SQL DB, Managed Instance)
83
95
- It is recommended to have a recent backup before making any index changes
84
96
- The multi-database processing feature (@get_all_databases) analyzes each database sequentially for better performance and resource management
0 commit comments