Throwing a timeout with an expired exception when executing a request from ASP.NET

I have a table with values ​​of 1,000,000 . From this I need to get some values ​​that fulfill my conditions. But when I execute the following request from ASP.NET, it throws a TimeOut expired exception. How to avoid this.

"SELECT ID,Intime,OutTime from [dbo].MasterLog WHERE CardId=(SELECT ID from User WHERE Name like 'ki%')" 

It will be very helpful if I get an answer. thanks in advance

+4
source share
4 answers

It looks like you need to add the index to the column in the where clause of your query.

check this

it's the same

  • Also think about Stored Procedures
  • Saved Coz procedures can significantly reduce data time from the database.
  • Always avoid writing a query in an interface.

But the first and most important thing is indexing. If you have more data, enter it.

+4
source

Besides updating your connection and team timeout, if you add a non-clustered index to CardID and include the column identifier, Intime, OutTime, which is the coverage index, your query will be faster, which 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 
+2
source
  • WEB.CONFIG TIMEOUT option long

  • IIS TIMEOUT Application Pool Option Long

  • (Current page) Request Header KeepAlive = true setting

+1
source

Try

  • Correctly specify the connection timeout and command timeout.
  • Add Index to Table on CardId
  • First select the TOP 100/1000 records and try to get the rest as and when needed to improve query performance.
0
source

All Articles