Register
Wednesday, September 08, 2010
 
 DBAs And ProgrammersBlog
  
News! Minimize
   
 
 Print   
 
Misc Blog Stuff Minimize
   
 
 Print   
 
The Reluctant DBA Minimize
 
 
 
 Print   
 
Reluctant DBA Minimize
   
 
  
 
Reluctant DBA Minimize
   
 
  
 
The Reluctant DBA Minimize
 
Oct15

Written by:CarpDeus
10/15/2008 7:30 AM 

If you want an introduction to LINQ to SQL (L2S), watch this video.  Then tell me what LINQ to SQL is supposed to do. My understanding is that it is supposed to make life easier for programmers. And, in certain situations, it might do that. But, on any project of any size, I don't see how it does. In fact, I see several problems with L2S. 

The first one is that this is distributed, compiled code and that is a pain to fix in a production environment. Let's say that you have a join between multiple tables. When the person responsible for the database, whether a DBA or not, sets up a stored procedure to return that data, it can easily be optimized outside of the compiled code. If I discover that changing the way that the joins are done to include a couple of more relevant columns produces a 30-percent reduction in retrieval time, that can be implemented without any changes to the distribtued, compiled code. If, on the other hand, your program is used by 5, 10, 100, or even thousands of people and it's a WinForm application, then you have to figure out how to get that new code out to every user. This, by the way, is one of the benefits to stored procedures.

But, you say, you can use stored procedures in L2S. They are very easy to set up as the Insert/Update/Delete for table objects and you can even use them to retrieve data.

Perhaps, but what you can't easily do is set up a stored procedure to return parts of a table object and cast them correctly back to the table object to let the Insert/Update/Delete work.

The second problem with L2S is the issue of the SQL it generates. Luca (the presenter in the video) talks about the complexity of the SQL generated compared to the simplicity of the C# code he is building.  Sorry, but that doesn't exactly make me all warm and fuzzy inside. Overly complex SQL leads to poorly performing SQL which leads to scalability issues. In fact, one thing I plan on doing is putting up my old test database and doing some simple testing using L2S and non L2S interfaces to see which perform best. 

Northwind is a great demo database. Hell, you can probably write a CROSS JOIN on all of the tables without poor performance1 precisely because it is small and inconsequential. When faced with real situations and real data and a project of any consequence, the penalties inherent in using L2S will become painfully obvious.

We shall see, in the coming weeks, just how well L2S really does or doesn't work.


1Actually, a full cross join of all tables returns no data, SQL Server is more intelligent than that.

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
 
 
  
 
Privacy Statement | Terms Of Use Copyright 2001-2008 by ReluctantDBA.com