SQL Server 2008 Test Ride (Part 1)

5 בדצמבר 2008

אין תגובות

This is my first post of two (maybe more, we’ll see 🙂 about some of the performance improvements you will experience when upgrading to SQL Server 2008 and Visual Studio 2008 SP1.


In this one we will be taking TVP (Table Valued Parameters) for a test ride.


Let’s compare the time it takes to insert a large number of rows into a table using the following methods:



  1. SqlDataAdapter (with different values of the UpdateBatchSize property)

  2. Multiple Inserts (delimited by semicolons)

  3. Packaging the rows to insert as XML and calling a stored procedure that receives it.

  4. A stored procedure with a Table Valued Parameter

Using the code:



  1. You must be using SQL Server 2008 and Visual Studio 2008 SP1.

  2. Download the code from the bottom of this post.

  3. Run the Setup.sql against the server.

  4. Modify the connection string in the project Settings.

  5. F5

  6. The code should be self-explanatory, but let me know if not.

Here are the results of just one run on my laptop for the insertion of 10,000 rows.


image


Conclusions:


TVP performs better than DataAdapter generated updates, and better than the relatively fast method of sending tables as XML.


The results aren’t entirely consistent each run, but TVP wins every time : )


Comments are welcome

הוסף תגובה
facebook linkedin twitter email

כתיבת תגובה

האימייל לא יוצג באתר. שדות החובה מסומנים *