-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Outline guiding principles and decide on direction for queries in 3.0 #12795
Comments
Including here the seminal client-side evaluation proposal Colin Meek wrote: Implicit boundaries in LINQ to Entities (client-side evaluation)OverviewLINQ forces us to blur the boundary between the server and the client. For a provider like LINQ to Entities, this means that a query supplied to the stack is always partly evaluated in the client application and partly in the database server. For instance, the query int productId = 1;
var q =
from p in context.DbSet<Product>()
where p.ProductID == productId
where DetermineProductPriority(p) == "High"
select new XElement(
"Product",
new XAttribute("Name", p.Name),
new XAttribute("ID", p.ProductId)); includes a selection evaluated by the server ( While we have found it convenient to talk about LINQ to Entities as a strict implementation – all server or nothing – and other implementations such as LINQ to SQL as hybrid implementations – splitting the query into client and server expressions – these implementations really exist along a continuum, and it makes sense to examine this continuum in more detail to clarify the current behavior and how we could improve EF. It is convenient to discuss this continuum with respect to the following expression scopes:
Note that these categories are somewhat arbitrary. A client source is a kind of independent sub-expression and a dependent sub-expression is in some ways just a generalization of client projections. The categories are still intuitively useful however: independent sub-expressions often map to parameters while client sources mostly map to scans, and; client projections are frequently benign while dependent sub-expressions are often cause for concern (consider high selectivity filters). Implicit boundaries are dangerous but also an essential feature of LINQ. Finding the appropriate balance is important. From feedback we have received over the years, we know that users expect magic and may be disappointed if we either throw because we’re overly strict or we end up streaming 1,000,000 rows from the database into the client to find the 10 rows matching a client predicate because we were too loose. Independent sub-expressions and client sourcesOptions:
Client projectionOptions:
Note that method calls may introduce additional round-trips to the server. Before people start shouting about “nanny state APIs”, consider that users are not complaining that they wanted the round-trips but that we failed to crack the methods to figure out how to avoid them… Dependent sub-expressionsWhat happens when a sub-expression cannot be evaluated by the server but depends on intermediate results?
Interface considerationsIf we implement support for these patterns, we should also consider allowing the user to disable them. The user can exercise whatever level of control they want over the client-server partitioning of the query. In addition, we should make the partitioned plan visible to the user, either by using documented boundary expressions or through a debugger visualizer. Implementation considerationsWe can include a separate pass to identify supported and unsupported expressions in the query tree, similar to other LINQ implementations. |
I love the example with As for architectural changes and managing query bugs, I feel like there is a lot I could say but I don't know how effective I would be at communicating it. |
@tuespetre I'm pretty sure we will want to talk to you about some of this stuff, so stay tuned. :-) |
@ajcvickers - In regards to looking at ReLinq. Is #12048 the driving issue behind that, or are there other things driving it as well? It seems like a major undertaking to remove/replace it given how the tightly the query system is architected around it with a lot of risks for breaking things. |
@pmiddleton Other things too, And yes, I agree that it is risky; that is one of the considerations. Sorry for being a bit ambiguous here. Like I said, stay tuned. Don't be impatient. 😉 |
@ajcvickers - I have the open PR for TVF and am currently working on a pivot feature. Both have tie-ins to ReLinq so the possible change peaked my interest as there might be some rework required on my part. :) |
@pmiddleton Agreed. |
@ajcvickers Heyyy, I’m onto you 👀 |
@smitpatel, @ajcvickers any need to keep this open now? |
I will write certain notes overall about things and close it. Or I can add it to the docs and close the issue with reference to it. |
Adding a version of this with your notes to a “query architecture” section in the docs sounds great. I guess we can create a docs issue for that and close this anyway. |
Even simple group by is broken in ef 3, why is this? Seems like a group by should translate to sql statement just fine... |
I second that question and also wonder how this situation makes any sort of sense. |
There are several query-related efforts being worked on or considered for the 3.0 release. This issue is a single place to track and discuss these efforts at a high level as we make progress and decide on direction.
Initial areas to consider:
The text was updated successfully, but these errors were encountered: