I'm having a problem with a Function which is taking 10 times longer to run than it used to and high CPU usage. And I'm puzzled by what I'm seeing in the execution plan with some index seek operators showing large discrepancies between actual and estimated row counts. For example an actual row count of 61 and an estimated row count of 269,445.
When I looked at the stats for the index associated with the highest-cost operator in the plan, its sampled rows count was about 10th of the actual rows so I ran a Full Scan. However that's made no difference. Now sampled rows and actual rows are the same but I'm still seeing large discrepancies between actual and estimated row counts for the same index. I was wondering if the high estimate was causing the plan to request a much higher memory grant than was needed however I can't understand where this high estimate is coming from so I was hoping someone might point me in the right direction.