UPDATE STATISTICS On Azure SQL DB

Vijay Kumar 2,036 Reputation points
2022-04-07T02:30:54.35+00:00

How to run UPDATE STATISTICS on entire DB in Azure SQL DB.

Azure SQL Database
{count} vote

Accepted answer
  1. Alberto Morillo 34,671 Reputation points MVP Volunteer Moderator
    2022-04-07T03:51:27.407+00:00

    My suggestion is to use Ola Hallengren scripts as shown below. Based on my own experience, updating statistics and defragmentation of indexes are very important for Azure SQL performance and to save money on Azure SQL.

    EXECUTE dbo.IndexOptimize
    @Databases = 'Alchavo30',
    @FragmentationLow = NULL,
    @FragmentationMedium = NULL,
    @FragmentationHigh = NULL,
    @UpdateStatistics = 'ALL',
    @OnlyModifiedStatistics = 'Y'
    GO
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ronen Ariely 15,206 Reputation points
    2022-04-07T02:40:20.503+00:00

    Hi,

    Basically it is done like SQL Server On-Premises

    TO update all statistics use:

    EXEC sp_updatestats;  
    

    And to update specific table you use:

    UPDATE STATISTICS Sales.SalesOrderDetail;    
    

    For full examples and explanation you can check the official documentation here:

    https://learn.microsoft.com/en-us/sql/t-sql/statements/update-statistics-transact-sql?view=sql-server-ver15&WT.mc_id=DP-MVP-5001699#next-steps


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.