Home Forums SQL Server 2012 SQL 2012 - General Execution plan when there are variables at the query is wrong RE: Execution plan when there are variables at the query is wrong

  • It's lack of parameter sniffing. The optimiser can't sniff the values of variables and hence assumes a default row count estimation.

    Usually fixed by either OPTION(Recompile) or OPTION(Optimize for ...)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass