I hit upon auto_update_statistics on google, it suggest if we make this ON we do not need to update Statistics, SQL Server will do it.
I was wondering so for any Insert, Update(of Indexed Column), Delete on Table will result in Update of Statistics? If yes will not that create latency for transaction.
Statistics do not get updated along with the insert/update/delete operations themselves. These operations just update a modification counter so SQL Server can keep track of how many changes there have been and whether an update is due.
When a query is executed that would use the statistics SQL Server checks whether the statistics are stale and updates the statistics if required.
The definitive article on the subject is Plan Caching in SQL Server 2008 (from which this flow chart is taken)
As mentioned earlier SQL Server maintains a count of the number of modifications made to each column. If the number of modifications since the plan was compiled exceeds the recompilation threshold (RT) then the plan will be recompiled and statistics updated. The RT depends on table type and size.
These recompilation thresholds are not suitable for all situations. e.g. see Statistics, row estimations and the ascending date column and traceflag 2371 can be used to modify the behaviour.
If
AUTO_UPDATE_STATISTICS_ASYNCisOFFthen the statistics are updated by the requesting spid before compilation can continue. If this option isONthen the statistics are updated by a system spid in the background and the original query is not blocked but just continues using the stale statistics.One additional way in which statistics can be updated is that rebuilding an index will also update the statistics with
FULLSCANat the same time.