• p.a.petrov (5/18/2015)


    The only thing that really coincides with the timing of the plans being regenerated is a DB maintenance job that we have: the daily index reorganizing (when fragmentation is 5-30%), and the daily index rebuilding (when fragmentation is more than 30%) job. Usually this daily maintenance job only does reorganizing (as the index fragmentation is never more than 30% on daily basis).

    And right there is your cause.

    Rebuilding indexes on a table will update statistics which will invalidate all plans which use the table. Reorganising shouldn't invalidate plans afaik, but I don't know if there's other stuff in that maintenance plan or if it's causing memory pressure resulting in a trim of the plan cache.

    In the long term I would suggest that you look at replacing the UDFs with optimal code. User-defined functions seldom perform well

    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