我有一个包含 1000000个值的表。从中我需要检索一些满足我条件的值。但是,当我从 ASP.NET 执行下面提到的查询时,它会引发TimeOut expired异常。如何避免这种情况
"SELECT ID,Intime,OutTime from [dbo].MasterLog
WHERE CardId=(SELECT ID from User WHERE Name like 'ki%')"
如果我得到答案,这将非常有用。提前致谢
除了更新你的连接和命令超时,如果你在 CardID 上添加一个非集群索引并包括列 ID、Intime、OutTime,这是一个覆盖索引,你的查询会更快,这将有所帮助。
CREATE NONCLUSTERED INDEX [IX_NCI_MasterLog_CardID] ON [dbo].[MasterLog]
(
[CardID] ASC
)
INCLUDE ( [ID],
[InTime],
[OutTime[)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
WEB.CONFIG TIMEOUT
选项很长
IIS 应用程序池TIMEOUT
选项很长
(当前页面)Request Header KeepAlive = true
设置
试试这些,