Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Feature: More agressive funcletization of client-side sub-expressions for improved performance [1586]

$
0
0
Item https://entityframework.codeplex.com/workitem/1574 shows a huge performance difference between a query that contains a predicate that looks like this:

```
... OrganizationPeriodId == (Commons.CurrentUser.IsActivePeriodLoaded ? Commons.CurrentUser.ActivePeriodId : 0) ...

```
which translates to something like this:

```
... [Join7].[OrganizationPeriodId] = (CASE WHEN (@p__linq__0 = 1) THEN @p__linq__1 ELSE 0 END)

```
And just simply evaluating the expression into variable and passing the variable down to the query:

```
var orgPeriodId = (Commons.CurrentUser.IsActivePeriodLoaded ? Commons.CurrentUser.ActivePeriodId : 0);
... OrganizationPeriodId == orgPeriodId ...

```
which will translate into something like this, that is better conditioned for the server to leverage indexes:

```
... [Join7].[OrganizationPeriodId] = @p__linq__0

```
The sub-expression is not correlated to anything on the server, it is just a pure client-side, so this is an example of something that we could automatically funcletize and produce better performing query.

More details about client-side evaluation are found in [our spec](https://entityframework.codeplex.com/wikipage?title=Implicit%20boundaries%20in%20LINQ%20to%20Entities%20%28a.k.a.%20client-side%20evaluation%29&version=2).



Viewing all articles
Browse latest Browse all 10318

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>