Reputation: 134
I am having a table with 1000000 values. From that I need to retrieve some values which are fulfilling my conditions. But when I executing the below mentioned query from ASP.NET it throws an TimeOut expired Exception. How to avoid this one
"SELECT ID,Intime,OutTime from [dbo].MasterLog
WHERE CardId=(SELECT ID from User WHERE Name like 'ki%')"
It will be very useful if I got the answer. Thanks in advance
Upvotes: 4
Views: 676
Reputation: 11
WEB.CONFIG TIMEOUT
option is long time
IIS Application Pool TIMEOUT
option is long time
(Current Page) Request Header KeepAlive = true
setting
Upvotes: 1
Reputation: 2594
Besides update your connection and command timeout, if you add a non-cluster index on CardID and include column ID, Intime, OutTime, which is a covering index, your query will be faster, that will help.
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
Upvotes: 2
Reputation: 1714
It sounds like you need to add an index to the column in the where clause of your query.
But first and most important thing is indexing, If you having more data means index it.
Upvotes: 4
Reputation: 1062
Try these,
Upvotes: 0