I was reading Kevin Holman’s script library on his blog page today and came across this query and was wondering if anyone had tried this yet. He gave the following SQL query to check and see how badly your Data Warehouse Database index is fragmented
–Show index fragmentation (to determine how badly you need a reindex – logical scan frag > 10% = bad. Scan density below 80 = bad): DBCC SHOWCONTIG DBCC SHOWCONTIG WITH FAST –(less data than above – in case you don’t have time)
I was thinking could we set up a rule to run this periodically and if it encounters an error run the following script he gave as a recovery?
–Reindex the database: USE OperationsManager go SET ANSI_NULLS ON SET ANSI_PADDING ON SET ANSI_WARNINGS ON SET ARITHABORT ON SET CONCAT_NULL_YIELDS_NULL ON SET QUOTED_IDENTIFIER ON SET NUMERIC_ROUNDABORT OFF EXEC SP_MSForEachTable “Print ‘Reindexing ‘+’?’ DBCC DBREINDEX (’?’)” –Table by table: DBCC DBREINDEX (‘TableName’)
Was just thinking it could help make SCOM self healing and keep performance at its max.