I need to fetch and show data on a webpage whose number of records may vary based on filters from around 500 records to 1 million records.
Will caching be of any use her
I concur with the rest of the answerers. displaying 1M records is ludicrous. However, you can display the first X records, and page through.
The trick is in the Stored Procedure doing the fetching
ALTER PROCEDURE [dbo].[MyHugeTable_GetWithPaging]
(
@StartRowIndex int,
@MaximumRows int
)
AS
SET NOCOUNT ON
Select
RowNum,
[UserName]
From
(Select
[ID],
[UserName]
Row_Number() Over(Order By [ID] Desc) As RowNum
From dbo.[MyHugeTable] t)
As DerivedTableName
Where RowNum Between @StartRowIndex And (@StartRowIndex + @MaximumRows)