我正在尝试提高相对复杂的实体框架查询的性能。使用DbContext.Database.Log
我在执行我感兴趣的主要查询时检查输出的操作,我发现了一些奇怪的东西。根据日志,查询本身只需要大约 10,000 毫秒,但是在查询“完成”和连接关闭之间有超过一分钟的时间。我不知道这次发生了什么,因为日志显示一个空白行。这是输出:
2018-09-07 14:10:34,641 [1] INFO EntityDataRepository [jobInstanceID: 0] - -- 执行于 2018 年 9 月 7 日下午 2:10:34 -07:00
2018-09-07 14:10:46,421 [1] INFO EntityDataRepository [jobInstanceID: 0] - -- 在 11776 毫秒内完成,结果:SqlDataReader
2018-09-07 14:10:46,458 [1] INFO EntityDataRepository [jobInstanceID: 0] -
2018-09-07 14:11:48,667 [1] INFO EntityDataRepository [jobInstanceID: 0] - 2018 年 9 月 7 日下午 2:11:48 -07:00 关闭连接
有人可以告诉我这里发生了什么吗?请参阅下面的代码的简化/通用版本:
(from child in entities.SelectMany(e => e.children.Where(childFilter))
join read in childReads on child.ID equals read.childID
join readType in readTypes on read.readTypeID equals readType.ID
where readFilter
select new {child, read, readType}).ToList()
catspeake
相关分类