Sql server statistics not updating
on secondary, so that I won’t impact the primary with the calculation and can serve my final customers.
Using the good old command DBCC SHOW_STATISTICS let’s take a look into our statistics object: All is fine in the kingdom and our stats are totally fine, with just 1 Million Rows accountable and those perky 1000 rows will eventually make part of the new statistics, calculated on the primary replica.
Well, enough for the pains & troubles, here comes the main idea: Dear Microsoft, allow us to use our secondary replicas to update statistics …
well and do much more stuff on the secondary replicas.
Temp Stats PRINT @script; EXECUTE sp_executesql @script; The following script above reads the imported value (yeah, I am doing one table sample here and do not care multiple statistics, threads, tables, databases, etc), creates the UPDATE STATISTICS statement, prints it out and then finally executes it.UPDATE 25th of June 2019: The item related to this topic on Azure Feedback: Allow Updating Statistics on the Secondary Replicas of the Availability Groups We all love and use the wonderful features of the Availability Groups on the secondary replicas, such as the Integrity Checks, Backups & co.