Monday, May 15, 2023

DBCC Commands in Microsoft SQL Server - DBA should know - Part - 2

DBCC INDEXDEFRAG:

Usage:

To defragment indexes in the database, we can use the DBCC INDEXDEFRAG command. Actually, when we fire the DBCC INDEXDEFRAG command in SQL Server, it runs & tries to reduce fragmentation and enhance the performance of the query. Also tries to reorganize all pages of clustered and non-clustered indexes which are available at leaf-level.

Example:

DBCC INDEXDEFRAG('<DatabaseName>,<TableName>,<IndexName>')

DBCC INDEXDEFRAG('AdventureWorksDW2016','DimSalesTerritory','AK_SalesTerritory')

Benefits:

It reduces fragmentation & improves the performance of the TSQL queries.

It also minimizes IO operation.


2) DBCC SHOWCONTIG:

Usage:

To fetch index fragmentation details from a database, we can use the DBCC SHOWCONTIG command. This command provides the organizational details of indexes which help the database administrator to catch fragmented indexes which may hit the performance of the query.  

Example:

DBCC SHOWCONTIG('<DatabaseName>,<TableName>,<IndexName>')

Benefits:

Helps database administrator to catch fragmented indexes which helps to address performance issues.

Helps to prepare maintenance strategies and index optimization plans.







No comments:

Post a Comment

Featured Post

Use DBCC SQLPerf (logspace)

 Use DBCC SQLPerf (logspace) to monitor and optimize database performance in SQL Server. Let's Explore: Let's Explore: https://mades...

Popular Posts