How can we improve WCF Data Services?

Use ParameterExpression to improve performance with EF5 auco-compiled query

Actually, when we do OData request, WCF Data Services will transform the URL to an expression tree. If we have parameters in our OData Request, these parameters are translated to a constantExpression on the Expression Tree.

EF5 will recompiled the full query each time we query with a new parameter value.

Example : http://localhost/WebApplication6/DataService.svc/Products(1) and http://localhost/WebApplication6/DataService.svc/Products(2) will be compiled twice.

It is possible to compile this query once by using a parameterExpression instead of a constantExpression.

Please, WCF Data Services Team, use parameterExpression instead of constantExpression, it will clearly boost a lot of OData query.

See http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/67573ffd-bab2-48d2-845b-f2172bd35564 for more details

44 votes
Vote
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
You have left! (?) (thinking…)
Cyril DURAND shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →
completed  ·  Mark Stafford responded  · 

This is now possible with the public providers released in 5.6.0, and we will soon publish a sample on our blog showing how to do exactly this.

2 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...
  • Jeremy Bell commented  ·   ·  Flag as inappropriate

    Also, this is a potential Denial of service vulnerability, because an attacker can not only craft requests that take longer than normal requests (thereby multiplying the effectiveness of their attack), but their requests would thrash any sql server plan caching, filling the cache up with nonsense and thus cause legitimate requests to be recompiled as well.

  • Jeremy Bell commented  ·   ·  Flag as inappropriate

    This one change may mean the difference between using WCF data services or not for any high-volume enterprise level data service. To do otherwise is simply not scalable enough to meet the demands of any non-trivial data service, so I'm quite surprised this isn't built-in already.

Feedback and Knowledge Base