Wednesday, October 11, 2006

 

Transact SQL SARGs (Search Arguments)

The term SARG (or search argument) is used to describe whether a Transact SQL WHERE clause will be able to take advantage of any indexes present on columns in a table.

For example, this can use an index:

SELECT SomeColumn FROM MyTable
WHERE SomeColumn LIKE ‘Whea%’
But this can not:

SELECT SomeColumn FROM MyTable
WHERE SomeColumn LIKE ‘%eat’

This important topic is covered in some detail in the following references:

pgs 351 - 368, Guru's Guide to Transact-SQL, Ken Henderson
pgs 318 - 326, SQL Server Performance Tuning Distilled, Sajal Dam

SARGs are also mentioned in this more general performance tuning article.



    

Powered by Blogger