Presents your SQL SERVER E-NEWSLETTER for February 6, 2003 <-------------------------------------------> OPTIMIZE QUERIES WITH SEARCH ARGUMENTS The optimizer in SQL Server uses search arguments (SARGs) to filter queries. When you use the Display Estimated Execution Plan icon in Query Analyzer, it will produce a graphical display of the execution plan. When you place the mouse over the lower rightmost graphical element, a pop-up window will display statistics regarding the table. At the bottom of the window is listed information regarding arguments. The arguments are the potential SARGs. They would be identified at the bottom of the window with an indication that the optimizer could be used to filter the data. There are guidelines to help a query qualify for a SARG that the optimizer can use: * The filtering formula is present in the WHERE clause. * A column of the table is in its raw format of the WHERE clause. * A constant or variable containing a constant value is in the WHERE clause. * An operator comparing the column and the constant or variable is involved. The filtering formula consists of the column, constant or variable, and operator. All three mechanisms must be present in the filtering formula. The operator for a SARG may be one of the following: * = * < * > * >= * <= * BETWEEN * LIKE When the wildcard is being used with the LIKE operator, and the position of the wildcard is at the beginning of the constant or variable, it will not be used by the optimizer. These operators most likely preclude the query from being used by the optimizer: * NOT * != * <> * !> * !< * NOT EXISTS * NOT IN * NOT LIKE ----------------------------------------