Note: this is built on [ MySQL ]
Say I have a master=>detail structure, represented with the following Linq query:
IQueryable query = from master in myschema_master
join detail in myschema_detail
on detail.correlator equals request.id
select new
{
Id = master.id,
Attribute = detail.interestingcolumn
}
Say that if I execute the following query directly against the database, my ~2M record set starts returning in ~2 seconds
(Note: this is not the query that the EF Provider is sending to the database for the statement above)
select *
from myschema_master
inner join myschema_detail
on myschema_master.id = myschema_detail.correlator
Say that I want Entity Framework to send ^ to the database. How do I prevent it from sending this garbage tacked on to the end of my inner join:
OR ((`Extent1`.`correlator` IS NULL) AND (`Extent2`.`id` IS NULL))
For context, the full query that is being sent to the database by the provider is:
SELECT
1 AS `C1`,
`Extent1`.`id`,
`Extent2`.`interestingattribute`
FROM `myschema_master` AS `Extent1`
INNER JOIN `myschema_detail` AS `Extent2`
ON ((`Extent1`.`id`) = `Extent2`.`correlator`)
OR (
(`Extent1`.`id` IS NULL)
AND (`Extent2`.`correlator` IS NULL)
)
Alsø wik: the id and correlator fields are nullable Int64 and cannot currently be modified, but I want to completely eliminate the null check that EF and the underlying provider are sending to the db. (master.id is null and detail.correlator is null) creates a worthless Cartesian product that just wastes processing time
Alsø alsø wik ...I tried executing with Configuration.UseDatabaseNullSemantics set to both true and false (...in separate round trips, wise guy) and neither removed the IS NULL equivalency check. It was a long shot, but I'd never needed to set the property explicitly so wasn't sure exactly what it would do.