IT Community - Software Programming, Web Development and Technical Support

Some Performance tuning tips about SQL Server Stored Procedures

This is a discussion on Some Performance tuning tips about SQL Server Stored Procedures within the Database Support forums, part of the Web Development category; * Always use qualified name when calling stored procedures. for example EXEC dbo.Your_Proc This is very common mistake which cause ...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > Database Support

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-04-2008, 06:12 AM
vadivelanshanmugam vadivelanshanmugam is offline
D-Web Trainee
 
Join Date: Jan 2008
Posts: 41
vadivelanshanmugam is on a distinguished road
Default Some Performance tuning tips about SQL Server Stored Procedures

* Always use qualified name when calling stored procedures. for example EXEC dbo.Your_Proc

This is very common mistake which cause an extra trip to procedure cache to get execution plan for execution. SQL Server compiles stored procedure on its first execution and store the execution plan in procedure cache to be reuse in subsequent call for same sproc. In order to get the execution plan it require qualified stored procedure name e.g. dbo.My_Proc (fully qualified name contain Server.Database.Owner.My_Proc). When owner name is not specified then initial cache lookup by object name fails as owner name was not specified. SQL Server then acquire exclusive compile lock on stored procedure and all the referenced objects including tables for recompilation. Next step SQL Server will resolve the object name to a objectID and before compilation it makes another trip to procedure cache by using object id that can result finding previous exection plan. But as you noticed this can cause blocking in certain situation where many SPIDs are calling same sproc frequently and while its is lock for compilation all the caller have to wait until sql server find the execution plan in cache or recompile the sproc.

So the rule of thumb is Always qualify your objects (sproc, tables, views, functions) with owner name.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Performance Tuning Tips About Sql Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:16 AM
Performance Tuning Tips About Sql Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:15 AM
Performance Tuning Tips About Sql Server Stored Procedures vadivelanshanmugam Database Support 0 02-04-2008 06:14 AM
SQL Server Undocumented Stored Procedures a.deeban Database Support 2 12-23-2007 11:20 PM
Executing SQL Server Stored Procedures With PHP - Executing stored procedures Jeyaseelansarc PHP Programming 1 07-19-2007 12:23 AM


All times are GMT -7. The time now is 03:17 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0