i have strange problem sql query generated entity framework. have lowing scenario:
(all times sql profiler, not ef code involved)
- i restart server
- i start sql proviler see times
- i run query app on ef - takes 12 seconds
- i copy query sql proviler sql query analyser - takes 340 ms
- i run query again app on ef - takes 12 seconds
- i run query again sql query analyser - takes 320 ms (i can repeat procedure on , on same result)
also, if run query sql query analyser directly after restart of server taking around 1 second first time , same scenario discribed above.
edit: found solution don't know why speeding query. still open question...???
i used .asnotracking method in linq query. if remove statement query executed in 320 ms. locking level ef uses notracking???
any hints/ideas great. markus
so, answer own question - after many days of searching opened microsoft incident.
the real reason still not clear somehow sql server choosing different execution plan query if executed on ef. there 3 solutions:
1) change indices on tables execution plan clear 2) add hint query (not possible right ef) 3) create plan_guide query in sql server
i desided use first solution.
Comments
Post a Comment