• @TheSQLGuru,

    Why the developer used ISNULL / CAST - not sure. Didn't make sense to me but even without those the execution plan remains the same. I'm also leary of suggesting using the RECOMPILE option a solution as that just reinforces bad coding practices IMO - unless it is the only justifiable option. But with that said, I did try this already 🙂 and did not witness any changes to the execution plan.

    And just to set the stage - I'm approaching this from an I/O perspective. We're moving to a new data center and one of the things we identified is we have a large volume of I/O. After researching our sql and reviewing various metrics we indeed to have some inefficient queries contributing to unnecessary I/O. So I'm simply looking at ways to cut this down.

    Also, just to set the perspective, this table contains currently around 60,000 records and grows every day. The distribution of data based on the BatchID is between 1 and 180ish records (per BatchID). I would expect in all cases an index seek and not a scan through every single record in the table.