Here’s what the statistics look like on the table in Object Explorer. If you want to verify which column is in each auto-created statistic, you can do that with this query: SELECT s.name, s.auto_created, s.user_created, as colname FROM sys.stats AS s JOIN sys.stats_columns as sc on s.stats_id=sc.stats_id and s.object_id=sc.object_id JOIN sys.columns as c on sc.object_id=c.object_id and sc.column_id=c.column_id WHERE s.object_id=OBJECT_ID('agg.First Name By Year') and s.auto_created = 1 ORDER BY sc.stats_column_id; GO Sure enough, here are our statistics, and they are on Gender and First Name Id.For SQL Server 2005 – SQL Server 2014 (with no trace flags) to make an optimization decision that the update is kicked off. Trace Flag 2371 makes the formula for large tables more dynamic.

sql updating table from another table-24sql updating table from another table-6sql updating table from another table-86

This trace flag changes the locking behavior associated with updating statistics.

With the trace flag on, if you set up jobs to concurrently update statistics on the same table, they won’t block each other on metadata related to statistics updates.

These are not considered ‘user created’ even though our user query was the cause of them being auto-generated.

(“User created” means someone ran a CREATE STATISTICS command.) SQL Server can now use the statistic on Gender and the statistic on First Name Id for future queries that run. First Name By Year table has a clustered primary key, and here is the statistic that was created along with that index: If columns are important enough to index, SQL Server assumes that it’s also important to estimate how many rows would be returned by that index when you query it.

I’ve been asked a lot of questions about updating statistics in SQL Server over the years. Here’s a rundown of all the practical questions that I tend to get about how to maintain these in SQL Server.

I don’t dig into the internals of statistics and optimization in this post. ⇒ Be a proactive: If you have millions of rows in some of your tables, you can get burned by doing no statistics maintenance at all if query performance stats to get slow and out of date statistics are found to be the cause.

Because why optimize a query on bad data estimates?

The thresholds for when auto-update statistics kicks in are a little complicated.

But in general it does NOT pay off to enable trace flags “just in case” for most people.