Using arithmetic operator wisely in predicate to improve performance

Arithmetic operation directly on the column name in the WHERE condition makes your condition non-sargable and index defined on the column will not get performance benefits. As long as possible, try to avoid this situation by logical workarounds to gain performance boosts.

Getting ready

There is no automatic way to find this behavior; this is simply a manual process. You either keep this step in mind while developing the SQL script or while working on performance tuning projects.

Let us use two tables from the AdventureWorks2012 database to demonstrate this exercise.

  • [AdventureWorks2012].[HumanResources].[Employee]
  • [AdventureWorks2012].[HumanResources].[EmployeePayHistory]

How to do ...

Get Microsoft SQL Server 2012 Performance Tuning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.