How to reduce Entity Framework 4 query compile time?

前端 未结 5 729
迷失自我
迷失自我 2020-12-30 12:23

Summary: We\'re having problems with EF4 query compilation times of 12+ seconds. Cached queries will only get us so far; are there any ways we can actually reduce the compil

相关标签:
5条回答
  • 2020-12-30 12:41

    You can try to use http://www.iis.net/download/ApplicationWarmup It is in beta now, but we regarding to use it too.

    0 讨论(0)
  • 2020-12-30 12:43

    You could create a view for some of your more complex queries which gives you complete control of the SQL. Then include that view in your data model.

    0 讨论(0)
  • 2020-12-30 12:47

    Make your queries simpler. Seriously; there's an almost linear relationship between query complexity and compile time. Two simple queries are often much faster than one really complicated query (even if precompiled!). If speed is the end goal, choose the fastest option.

    0 讨论(0)
  • 2020-12-30 12:49

    Take a look at nqueries, it uses precompiled queries, that are generated during application startup.

    Edit: Since the switch to EF5, NQueries does no longer support compiled queries as it switched to DbContext, if you still would like to take a look, take the 1.03 release source code, which is still ObjectContext based and supports compiled queries.

    0 讨论(0)
  • 2020-12-30 12:57

    This is likely not the answer you are looking for, but for a simple workaround why don't you run the CompiledQuery.Compile at the time the webapp gets initialized (do some dummy call to the webapp) instead of the first (customer) call.

    0 讨论(0)
提交回复
热议问题