多列左联接添加了不必要的过滤器

时间:2018-08-27 19:08:26

标签: c# sql oracle entity-framework

我有一个linq查询,它在多个列上连接了两个视图

from a in view1
join b in view2
on new { a.column1, a.column2, somefield = a.column3.Value } equals
   new { b.column1, b.column2, somefield = b.column3 } into joineddata
from d in joineddata.DefaultIfEmpty()
where d == null
select a;

它生成的SQL查询是

SELECT 
"Extent1"."COLUMN1" AS "COLUMN1", 
"Extent1"."COLUMN2" AS "COLUMN2", 
"Extent1"."COLUMN3" AS "COLUMN3", 
"Extent1"."COLUMN4" AS "COLUMN4", 
"Extent1"."COLUMN5" AS "COLUMN5", 
FROM "SCHEMANAME"."VIEW1" "Extent1"
LEFT OUTER JOIN "SCHEMANAME"."VIEW2" "Extent2" on 
(("Extent1"."COLUMN1" = "Extent2"."COLUMN1") OR (("Extent1"."COLUMN1" IS NULL) AND ("Extent2"."COLUMN1" IS NULL))) 
AND (("Extent1"."COLUMN2" = "Extent2"."COLUMN2") OR (("Extent1"."COLUMN2" IS NULL) AND ("Extent2"."COLUMN2" IS NULL)))
AND ("Extent1"."COLUMN3" = "Extent2"."COLUMN3")
WHERE "Extent2"."COLUMN1" IS NULL

我不明白为什么要在联接中为COLUMN1和COLUMN2添加“或”过滤器。 我需要配置什么告诉它不要添加那些OR过滤器?

使用这些OR过滤器会损害性能。

0 个答案:

没有答案