VahidN / EFSecondLevelCache.Core

Entity Framework Core Second Level Caching Library
Apache License 2.0
326 stars 51 forks source link

ToSql to slow, why not use Experession string= #26

Closed SteffenMangold closed 5 years ago

SteffenMangold commented 5 years ago

Summary of the issue

I have a more general question.

The ToSql function you are using is very very very slow. It brings an extreme high CPU workload to a heavy cache using service.

Why you don't use the _query.Expression.ToString() function as base to build the hash value for an IQueryable? I think it gives us to exact the same result but at much higher speed? Is there some point I'm missing?

VahidN commented 5 years ago

Nice finding! I used the ToSql method because it gave me the parameter values, not just a raw expression without any details. But it seems _query.Expression.ToString() gives the same result and contains the parameter values as well.

SteffenMangold commented 5 years ago

Nice finding! I used the ToSql method because it gave me the parameter values, not just a raw expression without any details. But it seems _query.Expression.ToString() gives the same result and contains the parameter values as well.

I think you have to reopen it. There is a problem with some parameter values. The complete problem is descript here: https://petemontgomery.wordpress.com/2008/08/07/caching-the-results-of-linq-queries/

There is also a logic to solve this. But it needs some more implementation.

SteffenMangold commented 5 years ago

I also created a question for the EF team. Maybe there is another solution. https://github.com/aspnet/EntityFrameworkCore/issues/14230

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.