Get-sqmIndexHealth
Performance
sqmSQLTool v1.9.196+ · Diagnostics
Per index (per partition for partitioned indexes): rows, pages, size, fragmentation (columnstore: share of deleted rows), fill factor, reads and writes since the last restart, and a status:
• Ok, Reorganize (from 5 %), Rebuild (from 30 %)
• Small (below -MinPageCount, fragmentation not measured), Disabled, NotMeasured (with -SkipFragmentation)
Fragmentation is read with
sys.dm_db_index_physical_stats in LIMITED mode, only for indexes at or above -MinPageCount pages. Works on read-only databases and AG secondaries. For unused, duplicate and overlapping indexes see Get-sqmIndexUsageReport.
Execution Flow
Parameters
| Parameter | Type | Required | Default | Notes |
|---|---|---|---|---|
| -SqlInstance | string | Optional | $env:COMPUTERNAME | Target SQL Server instance. |
| -SqlCredential | PSCredential | Optional | , | Credentials for the connection. |
| -Database | string | Optional | * = all user DBs | Database name or wildcard pattern. System databases only when named explicitly. |
| -Table | string | Optional | * | Table name or wildcard pattern. |
| -FragmentationLow | int | Optional | 5 | From this fragmentation (%) the status is Reorganize. |
| -FragmentationHigh | int | Optional | 30 | From this fragmentation (%) the status is Rebuild. |
| -MinPageCount | int | Optional | 1000 | Minimum index size in pages (8 KB) for the fragmentation measurement. |
| -ColumnstoreDeletedPercent | int | Optional | 20 | Columnstore: Reorganize from this share of deleted rows (%). |
| -SkipFragmentation | switch | Optional | $false | Metadata only (size, fill factor, usage). Fast, reads no index pages. |
| -OnlyProblems | switch | Optional | $false | Only indexes with status Reorganize or Rebuild. |
| -Summary | switch | Optional | $false | One row per database instead of one row per index. |
| -OutputPath | string | Optional | <OutputPath config>\IndexHealth | Directory for CSV + HTML report. Pass an empty string to skip the files. |
| -NoOpen | switch | Optional | $false | Do not open the HTML report after creation. |
| -EnableException | switch | Optional | $false | Throw exceptions immediately instead of logging and continuing. |
Examples
What would the next index maintenance do?
Get-sqmIndexHealth -SqlInstance 'SQL01' -OnlyProblems -OutputPath '' |
Format-Table Database, Table, Index, PageCount, FragmentationPercent, Status
One line per database
Get-sqmIndexHealth -SqlInstance 'SQL01' -Summary -OutputPath ''
Fast overview without reading index pages
Get-sqmIndexHealth -Database 'SalesDB' -SkipFragmentation -OutputPath ''