Re: Confused about proc vs. dynamic SQL vs LINQ



Ronald S. Cook wrote:

I've always been taught that stored procedures are better than
writing SQL in client code for a number of reasons:

- runs faster as is compiled and lives on the database server

Modern RDBMSs don't compile stored procs anymore, they evaluate any
query at runtime to execution plans which are optimized at runtime, not
at compile time. So, no, stored procedures aren't faster and no they're
not stored in compiled form.

- is the more proper tier to put it since is a data function

I think opinions differ on that ;)

But then I've heard that writing SQL in my client .NET code might run
just as fast? Dynamic SQL or something?

parameterized queries are as fast as procs and can be faster as you
can tailor dyn. SQL (parameterized!) to the job you have to do, so if
you have a table with 10 fields, you don't have to write a single
UPDATE proc which accepts values for all fields to update, you can
write an update query which updates just 1 field.

And then there's LINQ on the horizon. Is it a successor to
everything previously mentioned?

Linq is a language construct and the result of linq expressions,
expression trees, can be used to generate dyn. SQL at runtime, like any
other O/R mapper does these days.

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
.



Relevant Pages

  • Re: object databases
    ... No I never heard of SQLJ as I don't program in Java. ... SQLJ checks your SQL statements against the db. ... The compile time check is not mandatory. ... So you use an object oriented language, ...
    (comp.object)
  • Re: Setup of 2005 Dev edition Client Components fails
    ... And try SQL Server setup ... to compile: C:\Program Files\Microsoft SQL ... Microsoft SQL Server 2005 Tools -- Install started. ...
    (microsoft.public.sqlserver.clients)
  • Re: Setup of 2005 Dev edition Client Components fails
    ... to compile: C:\Program Files\Microsoft SQL ... Microsoft SQL Server 2005 Tools -- Install started. ... Then I installed the developer edition 10 different times. ...
    (microsoft.public.sqlserver.clients)
  • Re: Setup of 2005 Dev edition Client Components fails
    ... Report Server fails if Report Server service attempts to connect to the database that is not yet online. ... The install of SQL Server Developer Edition still fails. ... > to compile: C:\Program Files\Microsoft SQL ...
    (microsoft.public.sqlserver.clients)
  • Re: LINQ Queries vs Stored Procs
    ... Stored Procedures, you can limit the user to only executing stored ... most sql injection attacks, which are more possible with dynamic sql. ... Also about the security aspects: it's not as you claim it to be: I can ... I as a user in Marketing have to use your app which uses procs and I ...
    (microsoft.public.dotnet.languages.csharp)