Maintenance: Update Statistics

Antoine - Jul 18 '21 - - Dev Community

Photo by Ben Hershey on Unsplash

SQL Azure let you define maintenance windows.

But you can use a script to perform maintenance tasks such as updating index. This script has a lot of option.

DECLARE @dbname nvarchar(200) 
SELECT @dbname = DB_NAME()

EXECUTE dbo.IndexOptimize
@Databases = @dbname,
@FragmentationLow = NULL,
@FragmentationMedium = 'INDEX_REORGANIZE,INDEX_REBUILD_ONLINE',
@FragmentationHigh = 'INDEX_REBUILD_ONLINE',
@FragmentationLevel1 = 5,
@FragmentationLevel2 = 30,
@UpdateStatistics = 'ALL',
@OnlyModifiedStatistics = Y,
@Indexes = 'ALL_INDEXES',
@MinNumberOfPages = 1,
@LogToTable = 'Y'
Enter fullscreen mode Exit fullscreen mode

This blog explains how using it with Azure Automation, to perform it recurrently.

Hope this helps !

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player