SQL Server 2008. I have this very large query which has a high cost associated with it. TOAD has Query Tuning functionality in it and the only change made was the following:
Before:
LEFT OUTER JOIN (SELECT RIN_EXT.rejected,
RIN_EXT.scar,
RIN.fcreceiver,
RIN.fcitemno
FROM RCINSP_EXT RIN_EXT
INNER JOIN dbo.rcinsp RIN
ON RIN_EXT.fkey_id = RIN.identity_column) RIN1
ON RCI.freceiver = RIN1.fcreceiver
AND RCI.fitemno = RIN1.fcitemno
WHERE RED.[YEAR] = '2009'
After:
LEFT OUTER JOIN (SELECT RIN_EXT.rejected,
RIN_EXT.scar,
RIN.fcreceiver,
RIN.fcitemno
FROM dbo.rcinsp RIN
INNER JOIN RCINSP_EXT RIN_EXT
ON RIN.identity_column = COALESCE (RIN_EXT.fkey_id , RIN_EXT.fkey_id)) RIN1
ON RCI.freceiver = RIN1.fcreceiver
AND RCI.fitemno >= RIN1.fcitemno -- ***** RIGHT HERE
AND RCI.fitemno <= RIN1.fcitemno
WHERE RED.[YEAR] = '2009'
The field is a char(3) field and this is SQL Server 2008.
Any idea why theirs is so much faster than mine?