• The query is used for a rather complex computation needed in the result of a highly used stored procedure.

    Occasionally, the execution plan would include a Hash Join operator in a particular JOIN clause that worked well for some workloads, but ended up creating multi-million-row work tables for other workloads, where a paralel plan using the Merge Join, and Nested Loops, operators would have been more appropriate.

    Because of the complexity of the query (which someone else, other than myself should also be able to maintain ;-)), I didn't want to complicate things further, either by using explicit join hints (i.e. in specific JOIN clauses), or by specifying query-level join hints (e.g. OPTION(MERGE JOIN, LOOP JOIN), which would have prevented the use of the Hash Join operator altogether.

    OPTION(RECOMPILE) does cause some overhead (which isn't completely insignificant), but it keeps the behavior of this particular query predictable. Considering the full scale of what the procedure is used for, this is a highly significant benefit.

    ML

    ---
    Matija Lah, SQL Server MVP
    http://milambda.blogspot.com