MONUMENTAL SAVINGS
Buy 1, Save 35% or Buy 2+, Save 55%*—use code PD2019. Shop now.
Home > Blogs > And that's why you craft your queries very carefully
The other day I saw a question regarding re-use of query plans. The developer was using "exactly the same" query in two places, but the query plan wasn't being reused - there were a lot of recompiles.
In fact, the queries weren't the same. One had an extra space in a strategic location. That caused the query processor to view them differently, and recompile the statement.
While we're on the subject, it's always good practice to prepend the owner name (or schema in 2K5) to your queries:
EXEC production.usp_myproc
instead of
EXEC usp_myproc
Doing it the first way saves SQL Server the trouble of evaluating whether the object is unique to a database, and which owner (schema) to use.
Take advantage of special member promotions, everyday discounts, quick access to saved content, and more! Join Today.