-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Description
There are some null semantics optimizations we can do on SQL Server but not on other providers. We should consider making NullSemanticsRewritingExpressionVisitor provider specific.
example query:
ctx.Set<Weapon>().Select(
w => new
{
w.Id,
IsCartridge = !w.IsAutomatic && w.SynergyWithId == 1
})null semantics rewriting visitor when initially encounters this expression determines that it cant do optimized translation, since its in the projection,
so we get:
!w.IsAutomatic && w.SynergyWithId == 1 && w.SynergyWithId != nullhowever, later on those conditions get converted to CASE blocks, in which optimized translation would be allowed.
If null semantics would be a provider specific, it could always assume it can optimize conditions in projection (and maybe other places?), since search condition visitor will convert them all to CASE blocks.
Another optimization:
ctx.NullSemanticsEntity1.Where(e => e.NullableBoolA == e.BoolB == (e.IntA == e.NullableIntB)));on sql server we can apply optimized translation to the child comparisons, because they get converted to CASE blocks, on other providers we can't.