Thursday, April 17, 2008

SQL Server 2005 SP2 Cumulative Hotfix Packages and SQL Server 2005 Service Pack 3

The guys @ Microsoft have been busy improving the quality of SQL Server even more.

First of all CU7 was released (Build 3239) here.
As usual this means CU8 has been announced here.

I know there has been a lot of requests from the customers to release Service Pack 3 for SQL Server 2005. Although I see the benefits in the Incremental Servicing Model many people like the "certainty" of a good old service pack. Because Microsoft listens to its customers they have decided to release Service Pack 3 this year. More information can be found here.

Monday, April 14, 2008

Table Variable vs Parallelism

There are many myths surrounding table variables and one of the most common is probably the 'in memory' story. There are however a couple of other interesting facts about temp variables which you should also know about. The guys from the Storage Engine have an excellent post about table variables so you definitely have to read it.

One of the things that caught my eye in the post was the fact that queries do not go parallel when table variables are involved. This was actually something I had never come across so I decided to put it to the test. I borrowed a query from Craig Freedman who has an excellent series on parallelism. Here we go:

CREATE TABLE T (A INT, B INT IDENTITY, C INT, D INT)
CREATE CLUSTERED INDEX TA ON T(A)

SELECT COUNT(*) FROM T OPTION (MAXDOP 0)

UPDATE STATISTICS T WITH ROWCOUNT = 1000000, PAGECOUNT = 100000

SELECT COUNT(*) FROM T OPTION (RECOMPILE, MAXDOP 0)










DECLARE
@t AS TABLE
(NumberOfRows int)

INSERT INTO @t
SELECT COUNT(*) FROM T OPTION (RECOMPILE, MAXDOP 0)


For those of you who want to try it with a temp table:

CREATE TABLE #t
(NumberOfRows int)

INSERT INTO #t
SELECT COUNT(*) FROM T OPTION (RECOMPILE, MAXDOP 0)

DROP TABLE #t