We have a query in our C# / LINQ to EF code which consistently caused a timeout when run through our web application (ASP.NET MVC).
Error message:
Execution Timeout Expired.
The timeout period elapsed prior to completion of the operation or the server is not responding.
Running the SQL generated by LINQ directly in SSMS was almost instantaneous, regardless of the size of data returned or queried (we're using date ranges in the query).
This answer solved the timeout issue: we ran
exec sp_updatestats
on the db and now the timeout no longer occurs.
However, as was mentioned in the comments, does this solve the actual problem?
Does it prevent the problem from happening in the future?
Since the query didn't cause any issues running directly in SSMS, does this indicate a problem with ASP.NET / EF?
Or is a maintenance plan the correct approach? I don't know anything about maintenance plans. I see questions about rebuilding indices, backups etc. If I need a maintenance plan to prevent this timeout issue from occurring in the future, what type of plan must I set up?