Re: CRUD in SP or Dynamic SQL
- From: "PB" <A@xxxxx>
- Date: Tue, 24 May 2005 14:33:34 -0700
Stored procedures perform better than dynamic SQL. A stored procedure is
parsed and complied once (the first time it is executed). Every time you
subsequently execute the sp, the parsed/compiled version gets executed.
Dynamic SQL requires parsing and compiling on *every* execution. This is a
bit more runtime overhead - which negatively impacts your application's
scalability.
Also from a maintenance perspective - when you use stored procedures - you
have one place to make an update (in your SQL Server); whereas dynamic SQL
requires a recompile of your application and redistribution and
reinstallation. That's a whole lot of work - especially if the change is
small - and most changes are typically small.
It's a push regarding radical database schema changes (because app logic and
supporting sql will likely both change) - but such changes are typically far
less frequent in occurance compared to small changes.
Personally I'd opt for stored procedures over dynamic SQL for (1) improved
runtime performance; (2) simplified maintenance; and (3) protection against
SQL injection attacks.
-HTH
"MattC" <m@xxxxx> wrote in message
news:eWfzCGGYFHA.3760@xxxxxxxxxxxxxxxxxxxxxxx
> Hi,
>
> I'm implementing a new Business Layer in one of our applications. I'm
> toying with the idea of placing all the Create, Read, Update and Delete
> SQL
> in the object in question and build a dynamic SQL string using a class
> builder.
>
> The pros I can see are:
> It reduces the number of stored procs to admin.
> Changes to the underlying table schema does not require massive changes to
> large numbers of storeprocs
>
> The cons are probably I can se are:
> the potential for malicious code to be generated would be higher.
> The slight loss in performance do to no execution plan being available to
> cache.
>
> I would appreciate any ideas, opinions URL links etc
>
> TIA
>
> MattC
>
>
.
- Follow-Ups:
- Re: CRUD in SP or Dynamic SQL
- From: MattC
- Re: CRUD in SP or Dynamic SQL
- References:
- CRUD in SP or Dynamic SQL
- From: MattC
- CRUD in SP or Dynamic SQL
- Prev by Date: RE: Code Behind Page
- Next by Date: Re: Code Behind Page
- Previous by thread: Re: CRUD in SP or Dynamic SQL
- Next by thread: Re: CRUD in SP or Dynamic SQL
- Index(es):
Relevant Pages
|