I have a DB with about 2 million rows and I need to fix my current paging and have decided to go with the following:
SET @startRowIndex = ((@Page-1) * @PageSize) + 1;
SET ROWCOUNT @startRowIndex
SELECT @first_id = ProductID FROM LiveProducts (nolock) WHERE ManufacturerID=@ManufacturerID AND ModifiedOn >= @tStamp ORDER BY ProductID
SET ROWCOUNT @PageSize
SELECT * FROM LiveProducts (nolock) WHERE ManufacturerID=@ManufacturerID AND ProductID >= @first_id ORDER BY ProductID
I am no where near a DBA and I want this to be as fast as possible. What index(s) shoud i set on this thing. From my reading and my basic understanding I gathered I should create a no-clustered index on ManufacturerID, ProductID, and ModifiedOn.
But should they all be Index key column
s, or just one there and the others in Included Columns
?