Re: LINQ Queries vs Stored Procs
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Tue, 8 Jan 2008 19:02:12 -0000
Frank Calahan <ichbineinhund@xxxxxxxxx> wrote:
<snip>
Other than that, why should anyone would stop using SPs and start
using LINQ to SQL queries? Can anyone provide a reference that
refutes the guidance above from the Microsoft Patterns and Practices
Group?
The discussion I've seen isn't nearly as unbalanced as you've made out.
I won't go into all the details, but searching for "Frans Bouma"
"stored procedures" will go a long way. Alternatively, look at the
documentation for ORM projects (including the one Frans develops).
They're obviously bias in the other direction.
I'm very surprised to see the patterns and practices group put out what
looks like FUD. Let's see:
o Execution plan optimization and caching: this is done for prepared
statements too
o Passing less information across the network: yeah, like the size of
your SQL statement (excluding parameters which would have to be passed
in either way) is likely to be in any way significant traffic
o Putting responsibility into the hands of SQL experts: true, although
there's no reason not to get your DBAs to review your LINQ queries too.
In my experience, putting in this extra layer *mostly* results in a
lack of flexibility: if I want to do anything even slightly different
to what's already been done, you have to go to a lot more trouble with
the "always use SPs" mantra.
o Maintenance and security benefits: in certain situations I agree
about security. Personally I'd rather maintain code than stored procs,
although it's often easier to deploy a fixed stored proc once than
update all clients, of course.
o Countermeasure for SQL injection: not an issue for LINQ to SQL (or
any decent ORM or use of parameterized SQL) in the first place
Now, which issue are you actually concerned about? If it's performance,
I suggest you try it against *your* data, as that's what's going to be
really important.
In some cases stored procs certainly are the best way to go - but all
of the processing can be expressed in a single query statement, I
suspect you'll usually find that a tuned stored proc and a tuned LINQ
to SQL query will be very similar in performance. The tuning of both is
important, however. Also make sure when you do performance tests that
you take account of the slight hit incurred the first time a particular
query is executed in LINQ to SQL - don't just do one query and time
that; time lots of them.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
.
- Follow-Ups:
- Re: LINQ Queries vs Stored Procs
- From: Paul Shapiro
- Re: LINQ Queries vs Stored Procs
- References:
- LINQ Queries vs Stored Procs
- From: Frank Calahan
- Re: LINQ Queries vs Stored Procs
- From: Jon Skeet [C# MVP]
- Re: LINQ Queries vs Stored Procs
- From: Frank Calahan
- LINQ Queries vs Stored Procs
- Prev by Date: Impersonate in 2.0 Winforms
- Next by Date: Re: Windows Service Starts and Immediately Stops
- Previous by thread: Re: LINQ Queries vs Stored Procs
- Next by thread: Re: LINQ Queries vs Stored Procs
- Index(es):
Relevant Pages
|