• 1) Your WHERE clause is VERY complex for the optimizer, leading to bad estimates and both a suboptimal plan and multiple spills to tempdb for sorting.

    2) You have functions around columns in the WHERE clause, which contributes to the above and also can prevent the use of index seeks (if/when they are appropriate).

    3) Maybe your dev is underpowered 🙂

    4) You have date range filtering, which is almost an automatic OPTION (RECOMPILE) for the statement. I promise you don't want the same query plan for 1 day range as you do for a 10 year range!

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service