Re: Does nesting stored procedures make sense to increase performance?



Hi Sam,

Reducing client or middle-tier round trips to the database is a good idea in that it will reduce network traffic. Your milage in improving performance will depend on how close the middle-tier is to the database. In SQL Server 2000 (and earlier versions), because recompiles of query plans are done on a per-procedure basis, it's helpful some execute one SQL statement per procedure as well. In SQL Server 2005-2008 query plans are recompiled on a per-statement basis (not per-procedure) and statement-per-procedure does not assist in reducing recompiles.

If you're going to combine many calls into a single call, you'll need to add robust error handling to the "driver" procedure so as not to call procedures 2,3, and 4 if procedure 1 fails, etc. You'd need to replicate your existing client/middle-tier code's concept of success/failure results quit the batch of procedures on a failure and the return the results/return code that the client/middle-tier sees in the original. This will likely mean changes to the data access code as well.

Hope this helps,
Bob Beauchemin
SQLskills

"Sam" <Sam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:742C3C1C-4E9D-40C9-9C75-A73AC8640D67@xxxxxxxxxxxxxxxx
Hi,

I've recently became aware of nesting stored procedures in SQL Server. In my
public facing application, every page makes 2-4 database calls to retrieve
different pieces of the information. I know that database calls are expensive.

With that said, does it make sense to create a single stored procedure that
executes multiple stored procedures so that I can make a single database call
-- and call that one stored procedure? Would this make sense? Would this help
improve performance?

NOTE: If I don't do this, I'd be calling those stored procedures that will
be nested in that single SP, one by one hence making multiple database calls.
--
Thanks,

Sam

.



Relevant Pages

  • Re: Unable to view system stored procedures from .NET IDE and unable to debug SQL
    ... But what is the reason for the debug problem I mentioned below? ... try to step into a stored procedure in the Northwind database, ... Run SQL server setup or contact database ... I can't see any system stored procedures in master. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Database Model - Class, objects and interaction
    ... I was just proving stored procedures can call views. ... stuff like security and logging. ... So given 100,000 users, you would create database accounts for each? ... Part of our system's integrity was its reliability, and reliability is often assisted by simplicity. ...
    (comp.object)
  • Re: Identical database w/ identical stored procedures?
    ... > creating the maintence nightmare of updating the same stored procedure ... First of all, put your source code, tables, stored procedures and all ... This can be achieved with a help table in the database. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ...
    (comp.databases.ms-sqlserver)
  • Re: Database Model - Class, objects and interaction
    ... Stored procedures should only be used as a last resort if you cant use ... I've not said that views shouldn't be created, only that they shouldn't be exposed as the interface to the database. ... But business rules can be more complicated than simply defining overdue invoices. ...
    (comp.object)
  • Re: Debugging in VS.NET
    ... > "Cannot debug stored procedures because the SQL Server database is not ...
    (microsoft.public.sqlserver.msde)