DEV Community

Cover image for Maintenance: Update Statistics
Antoine
Antoine

Posted on

1 1

Maintenance: Update Statistics

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 !

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs