Avoid using local variables in your Select statements(sqlprof.com)
submitted by
ericvaillancourt(90) 4 years, 1 month ago
People are always surprised when I tell that their queries will run slower when they use local variables in their queries. Let me explain: If you use a local variable in a query predicate instead of a parameter or literal, the optimizer resorts to a guesstimate for selectivity of the predicate. Use parameters or literals in the query instead of local variables, and the optimizer will do a better selecting a query plan. For example, execute both of these queries.
|category: Database
|Views: 9
tags:
Database another
Everyones tags:
Your Tags: