I came across an article on Microsofts support site which has raised a point which I’d never considered before. It basically says that if the user that executes a stored procedure is not the owner of the procedure then locks are acquired during the process to find a cached plan that may lead to blocking. It also states this could be avoided by fully qualifying the sproc name (e.g. dbo.mysproc) when calling it to avoid the extra lookups. This has been a problem for me in the past since the projects I’ve worked on had been setup with an account running as dbowner, however, if I was setting up a database from scratch I’d set up a specific user(s) for accessing the database and give it just the permissions it requires (sproc execute permissions for example.) I think, therefore, this would fall into these problem. However, I would also make use of the schema prefix (e.g. Sales.Order table) rather than leaving it as dbo and therefore avoid this problem altogether.
September 21, 2009
1 Comment »
RSS feed for comments on this post. TrackBack URI

Just a quick thought though… this article related to SQL Server 2000 whilst I’ve be using 2005 and above for the last few years which introduced the schema prefix so I’m wondering whether the plan cache look up algorithm may have been improved to avoid this problem? I haven’t bothered looking since this isn’t an immediate problem but when it comes up in the future then I’ll be dusting off Profiler and testing the theory out.
Comment by Philip Hendry — September 21, 2009 @ 7:31 pm