Skip to content

Query: make null semantics optimizations provider-specific #18689

@maumar

Description

@maumar

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 != null

however, 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.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions