SQL Server basic algorithm for automatically updating statistics

Source: Internet
Author: User
When I first came into contact with SQLServer, I thought that the SQLServer data will be updated at the same time. In fact, SQLServer does not. Based on performance considerations, SQLServer uses the following algorithm to update statistics.

When I first came into contact with SQL Server, I thought that SQL Server would update statistics while changing data. In fact, SQL Server did not. based on performance considerations, SQL Server uses the following algorithm to update statistics

The basic algorithm for automatically updating statistics is:

· If the base number of the table in the tempdb database is less than 6, each of the six modifications will be automatically updated to the table.
· If the base number of a table is greater than 6 but less than or equal to 500, the update status is changed every 500.
· If the base number is greater than 500, when the table is updating statistics (500 + 20% tables), it is changed.
· Changing the base of a table variable does not trigger automatic update of statistics.

Note: strictly speaking, SQL Server calculates the base number as the number of rows in the table.

Note: In addition to the base, the selectivity of This predicate also affects AutoStats generation. This means that this statistical information may not be updated. For afer, the base number for each 500 modification is <500 or the base number for each 20% change seems to be> 500. Proportional factors (values range from 1 to 4, 1 and 4) are generated based on selectivity, this factor changes the actual number of modifications required to generate the product AutoStats of the number obtained from the algorithm.

In the form of a table, the algorithm above summarised can be used:
_________________________________________________________________________________
Table Type | Empty Condition | Threshold WhenEmpty | Threshold When Not Empty
_________________________________________________________________________________
Permanent | <500 rows | # ofChanges> = 500 | # of Changes> = 500 + (20% of Cardinality)
___________________________________________________________________________
Temporary | <6 rows | # ofChanges> = 6 | # of Changes> = 500 + (20% of Cardinality)
___________________________________________________________________________
Table
Variables | Change in cardinality does not affectAutoStats generation.
___________________________________________________________________________
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.