4

I am working on a small project that requires gridview paging for upto 100k records. what are the ways i can improve the performance. I tried to page using sql server with Temp table but it still is a bit on the slower side.

any idea?

3 Answers 3

9

You could add a stored proc that will return only a range of rows. Have the page keep track of what the current page you are on is, and request only the next x or previous x rows.

for example:

@firstRow   int,
@lastRow    int
select ROW_NUMBER() over (order by [MyField]) as rowNum, * 
from [MyTable] 
where rowNum between @firstRow and @lastRow 
2
  • Gotta love that ROW_NUMBER() function.
    – ProfK
    Jan 6, 2010 at 6:23
  • But Row_Number() will be slow in upper records because of order by. for example (between 100000 and 100010) is slower than (between 90000 and 90000010). what is your idea about it? Feb 6, 2012 at 17:52
1

Not sure Tj Kellie's idea will work. Here's an improvement:

select * from
(
select ROW_NUMBER() over (order by [MyField]) as rowNum, * 
from [MyTable] 
) 
as TableWithRows
Where Row<=20 and Row>=10

Will return rows 10 to 20. You can improve it further by adding select TOP [LastRow] before the ROW_NUMBER() function

0

Correction in query select * from ( select ROW_NUMBER() over (order by [MyField]) as rowNum, * from [MyTable] ) as TableWithRows Where RowNum<=20 and RowNum>=10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.