Analyze SQL indexes from the command line

The /analyzeindex command allows you to analyze index fragmentation and index-related statistics for the specified database objects.

Tip

To run the command line in Windows 11:

From the Windows taskbar

  • Click the Start menu or press Windows.
  • In the search bar, type cmd or command prompt. Select Command Prompt.

Using shortcut keys

  • Press Windows+R to open the Run command window. Alternatively, right-click the Start menu, then select Run.
  • Type cmd, then press Enter.

Syntax

dbforgesql /analyzeindex [/switch1[:value | [parameter1:value parameter2:value ..]] /switch2 ..]

Command-line details

Select the corresponding command-line switches to perform the required operations.

Argument Usage Description
/connection /connection:<connection_string> Specifies a connection string.
/database /database:<value> Specifies a database to manage indexes in.
/minindexsize /minindexsize:<value> Specifies the minimum index size in pages. The switch overrides the global option.
/password /password:<pw> Specifies a password. The switch overrides the password specified in the connection string.
/rebuildthreshold /rebuildthreshold:<value> Specifies the percentage of fragmentation that triggers an index rebuild.
The switch overrides the global option.
/reorganizethreshold /reorganizethreshold:<value> Specifies the percentage of fragmentation that triggers an index reorganize operation.
The switch overrides the global option.
/tempdbsort /tempdbsort:<On|Off> Overrides the Sort in tempdb global option.