Share via

UPDATE STATISTICS On Azure SQL DB

Vijay Kumar 2,061 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

Answer accepted by question author

  1. Alberto Morillo 35,506 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
    

    Was this answer helpful?

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ronen Ariely 15,221 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

    Was this answer helpful?


Your answer

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