SQL Server Interview Question #217
How can implicit conversions hurt query performance?
Advanced Query Optimization Senior Advanced
Detailed Explanation
An implicit conversion occurs when SQL Server automatically converts one data type to another so values can be compared or combined.
When the conversion is applied to an indexed table column, it can prevent an efficient seek and produce poor cardinality estimates. A common application example is comparing an NVARCHAR parameter with a VARCHAR column or using incompatible numeric types.
Application parameters should normally match the SQL column's data type, length, precision, and scale as closely as practical.
Code Example
-- Prefer a parameter whose SQL type matches the column:
SELECT Id, Email
FROM dbo.Users
WHERE Email = @Email;