• subscribe
September 19, 2001 12:00 AM

Coding an Owner Prefix to Avoid Recompilation

SQL Server Pro
InstantDoc ID #21890

Editor's Note: Send your SQL Server questions to Richard Waymire, Microsoft's group program manager for SQL Server management tools, at questions@sqlmag.com.

A sentence in your June 2001 column caught my eye: "Recompilations might be the source of the slower stored procedure speed." You recommend coding the owner prefix on all reference tables, views, and procedures. Should I incorporate this step into my coding standards to avoid suffering a performance problem? Can you give me more information about the circumstances under which recompilation occurs?

Yes, you should always code the owner prefix if you know it. Let's consider an example of why coding the owner prefix can improve query performance. When user Fred calls stored procedure dbo.foo, and dbo.foo executes the query

SELECT col1 FROM table1

the query optimizer must decide whether to retrieve fred.table1 or dbo.table1. Then, when user Mark calls the same stored procedure, the query optimizer must recompile the query plan to determine whether the user wants mark.table1 or dbo.table1. If you code the SELECT statement as

SELECT col1 FROM dbo.table1

the query optimizer encounters no ambiguity and avoids recompilation.



ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...