Re: Does nesting stored procedures make sense to increase performa



sloan,

Thanks for your response. I agree that it's not desirable and glad to hear
that it's OK to nest SPs into one.

I like the idea of calling individual SPs from one because it gives me the
ability to maintain each stored procedure individually. So if I make some
modifications in the stored procedure, this only affects that single SP.

I assume, by nesting SPs into one, I'd be returning multiple recordsets in
one stored procedure.
--
Thanks,

Sam


"sloan" wrote:



//every page makes 2-4 database calls to retrieve
different pieces of the information. I know that database calls are
expensive.//

That is less than desired.

Your optimal goal is "one page, one db hit"

So there is nothing wrong with nesting......I would lean toward Select
statements........
If you do other items other than Select, just be careful.


Here is a typical but simple example that is acceptable, and better than
calling each (sub) usp seperately.

But be careful, because what will happen is that you'll start putting a
bunch of "flag" parameters in the sub usp's and then it gets confusing.



IF EXISTS (SELECT * FROM sys.objects WHERE object_id =
OBJECT_ID(N'[dbo].[uspOrganizationGetAll]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[uspOrganizationGetAll]
GO

CREATE PROCEDURE [dbo].[uspOrganizationGetAll]
AS
BEGIN
SET NOCOUNT ON



exec [dbo].[uspDepartmentGetAll]
exec [dbo].[uspEmployeeGetAll]
exec [dbo].[uspJobTitlesGetAll]


SET NOCOUNT OFF
GO

GRANT EXECUTE ON dbo.uspOrganizationGetAll TO $(DBUSERNAME)

GO




"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: Enumerate stored procedures
    ... > I'm trying to code a stored procedure that will enumerate all the stored ... > procedures of a database, but I unable to separate the ... how can I tell which ones are system SPs ...
    (microsoft.public.sqlserver.programming)
  • Enumerate stored procedures
    ... I'm trying to code a stored procedure that will enumerate all the stored ... procedures of a database, but I unable to separate the ... how can I tell which ones are system SPs ...
    (microsoft.public.sqlserver.programming)
  • Re: Question on Database Project
    ... you don't have rights to access the SPs or you created the SPs in ... the wrong database. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... I get the error - "Stored procedure not ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... with the caveat that you don't recommend it because Microsoft ... of a stored procedure versus umpteen of the same stored procedure spread ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ...
    (microsoft.public.sqlserver.odbc)
  • Trying to set up a SQL Server Agent Account and I hit a wall....
    ... Our database is on SQL Server 2005, however it is set to compatibility mode ... You may need to set the compatibility level ... of the current database to a higher value to enable this feature. ... for the stored procedure sp_dbcmptlevel. ...
    (microsoft.public.sqlserver.security)

Loading