mssql_index_fragmentation
Analyze index fragmentation in SQL Server and get maintenance recommendations with ready-to-run ALTER INDEX statements. Handles REBUILD, REORGANIZE, and skips small indexes.
Instructions
Analyze index fragmentation and recommend maintenance: REBUILD (fragmentation ≥ 30%), REORGANIZE (5–30%), or OK (< 5%). Generates ready-to-run ALTER INDEX statements (ONLINE=ON suggested automatically on editions that support it). Small indexes below minPageCount are excluded since fragmentation there is harmless.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tableName | No | Optional: analyze only this table. | |
| minPageCount | No | Ignore indexes smaller than this many pages (default: 100 ≈ 800 KB). | |
| response_format | No | Response format (default: markdown) | markdown |