I'm working with an asp.net MVC4 project and using SQL Server 2008. My database table contains 100000 rows. Also max pool size of connection string property is set to 1000000 and pooling is set to true.
My table structure is as follows:
CREATE TABLE tblNews
(
ID int IDENTITY(1,1) NOT NULL,
Url nvarchar(300) UNIQUE NOT NULL,
PubDate datetime NOT NULL,
Active bit NOT NULL,
Hit int NOT NULL,
...
)
and there's an index as follows:
CREATE NONCLUSTERED INDEX indexTblNews_Url
ON tblNews(Url)
My select query is:
CREATE PROC spNewsGet
@Url nvarchar(300)
AS
UPDATE tblNews
SET Hit = Hit + 1
WHERE Url = @Url
AND PubDate > GETDATE()
AND Active = 1;
SELECT
*
FROM tblNews
WHERE Url = @Url
AND PubDate > GETDATE()
AND Active = 1
ORDER BY PubDate DESC
In low rated sites there is no problem and this works perfectly. But in database such big as 100000 rows and website having 2000000 single users / day, it crashes. It throws SqlTimeout
exception at one of three pages. When I click a page consequently nearly all of them gives above exception.
I've checked hardware performance and processor consumption is at %70 of I7 3.6 GHZ, ram consumption is 1.5 gb. But there is more empty ram memory. How can I overcome this problem?
Any helps would be very appreciated.