I recently worked with a client that uses a SQL Server 2008 data warehouse and was having performance issues while loading data. There were a number of issues to address, but one of the issues surrounded table statistics – more specifically, how and when they were to be maintained.
AUTO_UPDATE_STATISTICS
The first issue was the question about the load performance impact of auto stats. My client’s concern was that if this option was enabled that SQL Server would waste resources computing statistics over and over again while data was being loaded into the tables. The good news is that SQL Server does not compute statistics as data is loading into a table. The auto stats does not compute statistics until they are needed.
Take for example the following:
usemaster
GO
–Disable row counting
SETNOCOUNTON
GO
–Drop the DemoDatabase if it exists
IFEXISTS(SELECT*FROMsys.databasesWHERE name =‘DemoDatabase’)
Another point that was brought up during these discussions was whether it is necessary to update statistics for an index after the index is rebuilt. The answer is no. Rebuilding an index will automatically update your statistics even if AUTO_UPDATE_STATISTICS is set to off. This does not hold true however for reorganizing (defragmenting) an index. Only index rebuilds.