Here's a breakdown of what they were used for prior to SQL Server 2016:
Purpose of Trace Flags for Column Statistics
In versions of SQL Server before 2016, trace flags were used to modify how the query optimizer used statistics to create execution plans. This was important because:
- Statistics Importance: SQL Server maintains statistics about the distribution of data within columns and tables. These statistics are vital for the query optimizer to choose efficient ways to retrieve and join data.
- Outdated Statistics: If statistics become outdated (due to lots of changes in the underlying data), the query optimizer might make poor execution plan choices, leading to slow queries.
Specific Trace Flags
- Trace Flag 2371: This trace flag was a key tool for influencing when SQL Server considered column statistics to be outdated and in need of an update. Before SQL Server 2016, the thresholds for determining stale statistics were relatively static. Trace flag 2371 introduced a more dynamic threshold that adjusted based on table size, allowing for more frequent updates of statistics on larger tables.
Why This Matters
Using the right trace flags (especially 2371) helped DBAs and developers ensure the query optimizer had more up-to-date information. This was critical for maintaining optimal performance in SQL Server databases prior to 2016.
Changes in SQL Server 2016
In SQL Server 2016, the behavior introduced by trace flag 2371 became the default setting. This meant that database administrators no longer had to manually enable this trace flag to get the benefits of more dynamic statistics update thresholds.
The following diagram below shows you the different data that can be tracked.
Each explanation is followed by the name of the database column in parentheses.
View the image below to see how this data is displayed.