-
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
Generate better SQL for table splitting with required dependent #15521
Comments
This is because of #9005 |
Note from triage: As mentioned above, making dependents optional in table splitting scenarios, required EF Core to start reasoning about the columns mapped to the two entities separately, no matter if they are actually located in the same table. Also, there are new conditions added to the query to make sure that none of the values of the columns mapped to non-nullable properties is null, which we use to decide whether the dependent entity should be materialized. In the future we would go back to generating simpler SQL, but we need to implement this as a SQL generation optimization. Moving to backlog. |
Note to implementer: Client side materializer has to figure out when to materialize owned entity since Id would be always there when additional join is removed. That may require converting where predicate on client side. |
When I check Execution Plane of two queries; query cost of first one is about 28% and the second one is 72%. |
Blocked by #12100 |
We can't do the check on the client in the general case as we also need to check whether there are any dependents in the database |
@smitpatel Is this fixed now? |
Generated query in current master SELECT [e].[Id], [e].[IsDeleted], [e].[Name], [t].[Id], [t].[AlternateNumber], [t].[EmailAddress], [t].[MobileNumber]
FROM [Employee] AS [e]
LEFT JOIN (
SELECT [e0].[Id], [e0].[AlternateNumber], [e0].[EmailAddress], [e0].[MobileNumber]
FROM [Employee] AS [e0]
INNER JOIN [Employee] AS [e1] ON [e0].[Id] = [e1].[Id]
) AS [t] ON [e].[Id] = [t].[Id] Observations
SELECT [e].[Id], [e].[IsDeleted], [e].[Name], [e].[EmployeeDetail_AlternateNumber], [e].[EmployeeDetail_EmailAddress], [e].[EmployeeDetail_Id], [e].[EmployeeDetail_MobileNumber]
FROM [Employee] AS [e]"); |
@smitpatel Join elimination is covered by #18869, right? |
Yes. |
When load Parent And Child Entity in Table Splitting in EF Core before version 3.0 the select query is simple row select but when upgrade to ef core 3.0 the query contains self join and I think it's odd.
check this code please with EF core 3 and 2
the sql query for ef core 2 is
and for ef core 3 is
Further technical details
EF Core version: 3.0.0-preview4.19216.3
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017 15.7.4 & Visual Studio 2019
The text was updated successfully, but these errors were encountered: