博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

一个linq左连接查询速度问题

Posted on 2023-06-30 18:35  yiyanxiyin  阅读(26)  评论(0编辑  收藏  举报

var query = from a in _wfoReceiveFile.GetAll().Where(p=>p.CreateAccountId == loginId)
join b in _wfInstance.GetAll() on a.Id equals b.EntityId into temp
from b in temp.DefaultIfEmpty()
join d in _sysUnit.GetAll() on a.SendUnitId equals d.Id

select new ReceiveFileListOutput
{
 。。。。。。。。。。。。。。。
};

上面的linq数据量稍微大点,直接连接查询超时, 稍微改一下:

var query = from a in _wfoReceiveFile.GetAll().Where(p=>p.CreateAccountId == loginId)

join d in _sysUnit.GetAll() on a.SendUnitId equals d.Id

join b in _wfInstance.GetAll() on a.Id equals b.EntityId into temp

from b in temp.DefaultIfEmpty()

select new ReceiveFileListOutput

{
 。。。。。。。。。。。。。。。
};

速度马上上来了, 不知道啥原理, 就把红色那行往上移动了