Re: Stored procedure overhead - baffling - database gurus
From: Adam Machanic (amachanic_at_air-worldwide.nospamallowed.com)
Date: 03/11/04
- Next message: Tibor Karaszi: "Re: Physical reads"
- Previous message: Aaron Weiker: "Re: Query Plan Question"
- In reply to: Praty77: "Stored procedure overhead - baffling - database gurus"
- Next in thread: Tom Moreau: "Re: Stored procedure overhead - baffling - database gurus"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 11 Mar 2004 13:09:55 -0500
This article has instructions on determining whether your sproc is
recompiling and/or not caching properly:
http://www.sqlservercentral.com/columnists/bkelley/procedurecache_printversi
on.asp
Also, you should consider switching
If (Select count(trade_id) from trade_transaction where trade_id =
@TradeID) = 0
to
If NOT EXISTS (Select * from trade_transaction where trade_id =
@TradeID)
This will generally perform much better, as the server only has to find one
row matching the criteria to answer the EXISTS question, whereas for a
COUNT(), all rows must be found.
"Praty77" <praty77-google@yahoo.com> wrote in message
news:6c19a8f5.0403111003.540f2c4e@posting.google.com...
> Hello -
> I hope some database guru will enlighten me with this unique
> situation. There appears to be significant overhead in encapsulating a
> simple sql query in a stored procedure.
>
> I have a simple procedure fsp_getstatus (@tradeid integer)
> defined as:
> declare @status_num decimal
> If (Select count(trade_id) from trade_transaction where trade_id =
> @TradeID) = 0
> set @status_num = -1
> return @status_num
>
>
> If I run the proc, it takes 30 ms. If i run the raw statements
> (without the return of course), it takes 0 ms. This proc is called
> hundreds of times by one of our other stored procedures, and this 30
> ms delay (that has surfaced recently) is causing us severe performance
> problems.
>
> how much overhead is caused by running a stored procedure, compared to
> a simple sql statement? Is there any reason why this overhead would
> shoot up all of a sudden?
>
> I could not find any help in documentation, hopefully some gurus can
> enlighten me.
>
> Thanks in advance
> praty
- Next message: Tibor Karaszi: "Re: Physical reads"
- Previous message: Aaron Weiker: "Re: Query Plan Question"
- In reply to: Praty77: "Stored procedure overhead - baffling - database gurus"
- Next in thread: Tom Moreau: "Re: Stored procedure overhead - baffling - database gurus"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|