Performance mismatch of Entity platform versus Sql Management Studio

I am getting timeouts with a very simple EF instruction. I am just making a selection from one table with Entity.Title.StartsWith ("test") and .Take (25). When I run this for a search that returns no results, I get a timeout.

If I profile and grab the sql statement it looks fine, and if I run this sql in Management Studio it takes a split second!

Why does the same request trigger jogging in Management Studio and timeout when EF is generated and called from Asp.Net application?

+2


a source to share


1 answer


You probably need to rebuild the statistics.

This is a common symptom of an incorrectly cached query plan due to outdated statistics.

See this answer: Why are there performance differences when calling an SQL function from an application. Net when the same call is made in Management Studio .



This will update all statistical and updated views and stored procedures (but be careful when running on a production machine):

EXEC sp_updatestats 

EXEC sp_refreshview  

-- Probably won't need this as your are not using stored procs 
EXEC sp_msForEachTable 'EXEC sp_recompile ''?''' 

      

+4


a source







All Articles