尝试从数据库中异步获取有条件的前1个数据时发生超时错误

问题描述 投票:1回答:1

我正在尝试在特定条件下获取数据,我只希望使用entuity框架异步获取最新的一个数据,我编写了查询语句,它适用于特定的id,而对于其他对象,它给出了timeput错误。

 await _context.Data
     .Where(m => m.Thumb== thumb)
     .OrderByDescending(m => m.ReceivedTime)
     .FirstAsync();
c# entity-framework .net-core entity-framework-core
1个回答
1
投票
不,它们不是索引列

所以,解决这个问题;以下任何一项:

create nonclustered index NCI_Data_Thumb_ReceivedTime on [Data] (Thumb, ReceivedTime) create nonclustered index NCI_Data_Thumb_ReceivedTime on [Data] (Thumb, ReceivedTime desc) create nonclustered index NCI_Data_Thumb on [Data] (Thumb)

应该帮助

((注意:请遵循您自己的本地命名约定)]

© www.soinside.com 2019 - 2024. All rights reserved.