Owner Qualification in SQL? Huh?
Depending on your SQL setup and user accounts, it is possible to have the same table name in a database with different owners. I would not advise it, but SQL allows for it… And I am sure there is a reason for this…
Examples:
dbo.Employees
chris.Employees
sqlhero.Employees
Which table does this statement get data from?
SELECT *
FROM Employees
Answer… It depends on your SQL username. When doing a SELECT, you could get the wrong table. (Also applies to other object types like stored procedures, views, etc)
So, it is generally a good idea to qualify the owner of your SQL objects.
SELECT *
FROM dbo.Employees
Anyway… the primary reason for the post…
There is a great article on sqlblog.com discussing an even more “real world” reason for explicitly qualifying the owner. PERFORMANCE!
http://sqlblog.com/blogs/linchi_shea/archive/2007/07/05/performance-impact-of-procedure-calls-without-owner-qualification-sql-server-2000.aspx
In the post, Linchi Shea does a great job of explaining the performance impact of fully qualifying your object owners. In his example, you will see in SQL 2000 it makes a BIG difference in performance. SQL 2005 is a little faster too. But, every little bit helps when you have thousands of users calling the same procedure!
