zzzprojects / EntityFramework-Classic

Entity Framework Classic is a supported version of the latest EF6 codebase. It supports .NET Framework and .NET Core and overcomes some EF limitations by adding tons of must-haves built-in features.
https://entityframework-classic.net
Other
102 stars 27 forks source link

How to share query plan accross query DbContext instances ? #38

Closed chkeita closed 5 years ago

chkeita commented 5 years ago

While profiling our asp.net application we discovered that a new execution plan seems to created every time the request is executed. The test sends 20 requests to the server which triggers the same request to the database. Each database request is executed on new DbContext instance.

Is there an option to cache the execution plan across instances of Db ?

This screenshot shows the cumulative time spent by multiple requests creating the execution plan. image

JonathanMagnan commented 5 years ago

Hello @chkeita ,

By default, query plan is already shared across DbContext instance.

It uses the QueryCacheManager that is shared in the workspace to all your DbContext instance.

Is it possible for you to provide a runnable project that show this error (you can send it in private here: info@zzzprojects.com)

It will help us to understand your current issue. It might be caused because the plan is slighty different or another reason that we are not aware yet.

Best Regards,

Jonathan

JonathanMagnan commented 5 years ago

Hello @chkeita ,

Can we close this issue? I believe we got no reply from your side.

chkeita commented 5 years ago

I missed the notification for the first answer. Unfortunately, I am not allowed to share our code. But I will try to create a repro. I am not exactly sure how this is going to take so we can close this for now. And I will reopen it once I have the repro.