Short answer: the SQL Server optimizer will know that the table was truncated, but statistics might not update when you expect.
For the long answer, let’s walk through an example using the WideWorldImporters sample database.
Whether I’m working as a DBA, a consultant, a teacher, or just answering questions in my inbox, I always end up needing a script to inspect statistics one way or another.
Here are some freshly written scripts for a classic DBA question: what’s going on in my stats?
Want to learn more about managing statistics updates in SQL Server? Watch my 27 minute presentation on managing statistics.
I’ve been asked a lot of questions about updating statistics in SQL Server over the years. And I’ve asked a lot of questions myself! Here’s a rundown of all the practical questions that I tend to get about how to maintain these in SQL Server.
What are statistics? How often should you update them? Do you need a trace flag to make this easier? What are duplicate statistics, and do you need to drop them?
Join me for a live Hangout on Monday, April 18 at 8:30 AM Pacific / 11:30 AM Eastern to up your maintenance game!
It can be pretty difficult to manage statistics in data warehouses, or even OLTP databases that have very large tables.