You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Query: in case of joins, we shouldn't be materializing Inner if the qsre itself is not present in final projection #10210
fromginctx.Gears
join innerin(fromg2inctx.Gearsselectnew{g2.Nickname}) on g.Nickname equals inner.Nicknameselectg;
produces the following query plan:
(QueryContext queryContext) => IEnumerable<Gear> _InterceptExceptions(
source: IEnumerable<Gear> _ShapedQuery(
queryContext: queryContext,
shaperCommandContext: SelectExpression:
SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOrBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname]
FROM [Gears] AS [g]
INNER JOIN (
SELECT [g2].[Nickname]
FROM [Gears] AS [g2]
WHERE [g2].[Discriminator] IN (N'Officer', N'Gear')
) AS [t] ON [g].[Nickname] = [t].[Nickname]
WHERE [g].[Discriminator] IN (N'Officer', N'Gear'),
shaper: (BufferedOffsetEntityShaper<Gear>
materializer: (TransparentIdentifier<Gear, <>f__AnonymousType227<string>> t0) => t0.Outer)),
contextType: TestModels.GearsOfWarModel.GearsOfWarContext,
logger: DiagnosticsLogger<Query>,
queryContext: queryContext)
We actually don't need to materialize inner, so the materializer could be simplified by stripping the transparent identifier.
Another case that could also be improved, is when element of the inner is present in the final projection, but the inner qsre is not. In that case, we also don't need to materialize the inner and we can directly bind to the value buffer instead:
fromginctx.Gears
join innerin(fromg2inctx.Gearsselectnew{g2.Nickname}) on g.Nickname equals inner.Nicknameselectnew{g,inner.Nickname};
[ConditionalFact]publicvirtualvoidAnonymous_projection_AsNoTracking_Min(){AssertQueryScalar<Order>(
os =>os.Select(o =>new{A=o.CustomerID,B=o.OrderDate}).AsNoTracking()// Just to cause a subquery.Select(e =>e.B));}
This causes the selector to be evaluated on client. With aggregate operator like Min/Max causes really bad query. Eliminating anonymous types would be helpful in such cases.
Activity
smitpatel commentedon Nov 2, 2017
Also related #9892
smitpatel commentedon Apr 11, 2018
This causes the selector to be evaluated on client. With aggregate operator like Min/Max causes really bad query. Eliminating anonymous types would be helpful in such cases.
maumar commentedon Sep 11, 2019
verified this issue has been fixed in 3.0
Adding regression tests for issues that have been fixed already
Adding regression tests for issues that have been fixed already