none
MVC3 EF5 query plan caching RRS feed

  • Question

  • I have MVC3 project with target framework 4.0. I am developing under VS2010. I have .NET 4.5 installed of my machine. I use PostgreSQL as database server.

    I read that EF4 and DbContext does not support compiled query and query plan caching.

    So i just changed referenced library from EF4 to EF5, because this version caches query by default and i am still using MVC3 and VS2010.

    In VS2010 i cannot set target framework 4.5 for my web project, but i set it in web.config file.

    SO my question is:

    How can i determine, if EF5 in my MVC3 really caches autocompiled LINQ queries? Is there any static class or tool, which contains these queries or?

    Thanks. Regards



    • Edited by dEVIANT22 Monday, April 14, 2014 5:44 PM
    Monday, April 14, 2014 4:08 PM

Answers

  • >>So my another question is: Support EF 4.4 and DbContext autocompiled queries or not?

    It is supported from EF5, EF 4.4 does not have this feature.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by dEVIANT22 Thursday, April 17, 2014 12:21 PM
    Thursday, April 17, 2014 9:53 AM
    Moderator

All replies

  • Hello,

    >>How can i determine, if EF5 in my MVC3 really caches autocompiled LINQ queries?

    I am confused why you want to determine, if you are using EF5, it caches autocompiled LINQ queries by default. And if you do not want to use query plan caching, to set the EnablePlanCaching property (on EntityCommand or ObjectQuery) to false.

    >> Is there any static class or tool, which contains these queries or?

    There is a query plan cache, if query plan caching is enabled, the next time the query is executed the store command is retrieved directly from the query plan cache for execution, bypassing the plan compiler. And the query plan cache is shared across ObjectContext instances within the same AppDomain.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, April 15, 2014 3:05 AM
    Moderator
  • Thanks for reaction.

    I am using DbContext. I just want to check by some tool or something whether that query is really autocompiled and for the second time retrieved from cache, because i read that EF5 under NET4.0 has some limitations. And i cannot set in VS2010 for MVC3 project .NET4.5 as target framework, so i just change it in web.config file.

    Tuesday, April 15, 2014 6:29 AM
  • >>because i read that EF5 under NET4.0 has some limitations.

    Yes, this is. It is EF 4.4 version with .NET 4.0.

    >>I just want to check by some tool or something whether that query is really autocompiled and for the second time retrieved from cache,

    I think you can use two datetime variables, for example, start and end, and put them to before and after the LINQ query, running the query, and calculate usage time for first and second times. It should shows the second time will faster than fisrt time if it autocompiled.

    I think this article you may be interested:

    http://msdn.microsoft.com/en-US/us-us/data/hh949853.aspx


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 16, 2014 6:43 AM
    Moderator
  • Thanks.

    So i used stop watch, and everytime query takes about 200ms to execute. So i think, my queries are not autocompiled.

    So my another question is: Support EF 4.4 and DbContext autocompiled queries or not?


    Wednesday, April 16, 2014 12:09 PM
  • >>So my another question is: Support EF 4.4 and DbContext autocompiled queries or not?

    It is supported from EF5, EF 4.4 does not have this feature.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by dEVIANT22 Thursday, April 17, 2014 12:21 PM
    Thursday, April 17, 2014 9:53 AM
    Moderator