Update your SQL Server statistics !

Oopps! Upgrade your browser pretty please.Oopps! Upgrade your browser pretty please.

Just want to drop a quick note about the importance of updating your SQL Server database statistics. At a client we have recently moved a database to a newer version of SQL Server. As part of that you should always rebuild all your indexes and update all your statistics with FULLSCAN. This time however, it turned out that it was a little bug in the script used to update statistics, so it was not done with fullscan. What happened next was that when we tested some reports that took about 2 and a half minutes to run on the old system, they took almost 12 minutes on the new one. Bummer. Looking at the query plan, we discovered some big differences between estimated number of rows and actual number of rows, wich tipped us of. After properly updating statistics, the query ran in 4 seconds!