This is an excerpt from a large SQL statement. PS alias is a table in FROM clause of parent SQL statement
WHERE
(
ISNULL(PS.HRKY,'')=''
OR
(
ISNULL(PS.HRKY,'')<>'' AND EXISTS
(
SELECT 1
FROM SCHEME B
WHERE
PS.COMPANY=B.COMPANY AND
PS.PBS_MP_CODE=B.MP_CODE AND
PS.PBS_SEQID=B.SEQ_ID AND
B.FIELD_COMB LIKE '%CAT%' AND
B.VALUE_COMB LIKE '%'+@catName+'%'
)
)
)
AND
(
/*repeated with different columns*/
)
This is one of the 8 conditions that the where clause has of the larger statement.
My question is can I somehow short circuit the conditions without affecting their outcome to reduce computation?
WHEREclause first, and the others in any order, if it deems it be beneficial for the execution plan. - Tim Biegeleisen'%SOMETHING%'conditions because they basically neuter any indexes on those columns - even'SOMETHING%'would be an improvement. - AlwaysLearning