Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
No Math In Where Clause
Don’t use arithmetic operators on a column in the where clause
You will get an index scan instead of a seek. It is better to move the operation away from the column.
- SELECT * FROM Orders WHERE OrderID*3 = 33000
- SELECT * FROM Orders WHERE OrderID = 33000/3
Take a look at the execution plan of these two queries
Contributed By: --SQLDenis 15:26, 31 May 2008 (GMT)
Section Query Optimization