Performance issue using a variable

  • Hi, I have a very resource intensive query that I tested using a direct criteria eg where field='x'. Whilst testing on a sample of 1 row, this took 2 seconds. When I substitute the field='x' to field = @variable where I have defined the variable to be 'x' it takes 43 seconds..... ??

    This is driving me nuts and i cant understand why such a difference, any ideas guys?

  • http://sqlinthewild.co.za/index.php/2008/02/25/parameter-sniffing-pt-2/

    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

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply