Programmer's Corner Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Programmer's Corner - Forums


which one is faster in performance either storedprocedure or

 
Post new topic   Reply to topic    Programmer's Corner Forum Index -> SQL Server 2005
Author Message
sankar.nvss
Grasshopper


Joined: 08 Sep 2008
Posts: 1

PostPosted: Thu Sep 11, 2008 12:32 pm    Post subject: which one is faster in performance either storedprocedure or Reply with quote

HI

which one is faster in performance either storedprocedure or function in SQL server and why.Could any please give me the in depth knowledge.




Thank you very much in advance
Back to top
DiskJunky
Grasshopper


Joined: 11 Jun 2004
Posts: 17

PostPosted: Fri Oct 03, 2008 1:57 pm    Post subject: Reply with quote

I think I remember reading on the msdn that the stored procedure is faster as the caching is optimized for hit but you'd be as well off checking the msdn yourself to verify this - it was some time ago that I came across it
Back to top
ModusPonens
if A then B, if B then C...


Joined: 22 Oct 2004
Posts: 363
Location: Baltimore

PostPosted: Fri Oct 10, 2008 5:52 pm    Post subject: Reply with quote

Yes, a stored procedure is faster because the sql has already been run through the optimizer and compiled. Having said that, the optimizer looks at the current state of the tables being used and gives you the best execution; over time that compiled procedure may become out dated. It is a good idea to recompile the stored procs from time to time.

The greatest benefit to stored procs is they add a level of security; the proc accepts parameters which are declared as types which can help stop an injection attack. Plus stored proc can execute multiple routines and check parameters for content before using them.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Programmer's Corner Forum Index -> SQL Server 2005 All times are GMT - 5 Hours
Page 1 of 1

 


Powered by phpBB © 2001, 2002 phpBB Group