Recomplie option

  • Hi, can any one tell me when we need to use recompile option in Stored proc ?

    How can we figure out it ?

    Is execution plan show any sign that SP needs recompilation?

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • When the query(s) have no single optimal plan. One example is when you have severe parameter sniffing, data skew or similar.

    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
  • GilaMonster (5/7/2010)


    When the query(s) have no single optimal plan. One example is when you have severe parameter sniffing, data skew or similar.

    how do we come to know this ?

    through exec plan ? how ? please explain or direct me to any link ?

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • There is no hard and fast formula as in "You MUST use it here, you MAY NOT use it there." It's a case by case basis.

    However, one general rule you could apply, if the procedure builds dynamic TSQL statements, then it might benefit from the recompile option.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

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