Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Speeding up GridView

Reply
Thread Tools

Speeding up GridView

 
 
tshad
Guest
Posts: n/a
 
      02-04-2010
I have a GridView in my pages that is very slow since I am sending all the
data back from server and letting the GridView handle the paging.

I need to change that since in one of my projects I could have a couple
thousand rows sent back.

Where does the GridView put the data when it is doing the paging?

Does it call the Sql Server each time it pages it?

I am planning to change the code so that the paging is done on the server.
My Sql would look something like:

With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY LastName, FirstName) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > 40 AND ResultSetRowNumber <= 50

Where the Order By and row number would be dynamic.

Would I have to set this up as a dynamic SQL to accomplish this?

Or could I do something like:

With PagedResults AS
(
SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
OVER (ORDER BY @SortColumns) AS ResultSetRowNumber
FROM HumanResources.vEmployee
)
SELECT *
FROM PagedResults
WHERE ResultSetRowNumber > @StartRow AND ResultSetRowNumber <= @EndRow

Thanks,

Tom


 
Reply With Quote
 
 
 
 
Jonathan Wood
Guest
Posts: n/a
 
      02-04-2010
The datasource control is retrieving the entire results, and then displaying
only those for the current page.

Set your data source to an object, and there is an option to have arguments
for the starting record and number of records. Your method will then need to
retrieve only those rows from the database.

This is critical for any database of substantial size.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"tshad" <> wrote in message
news:...
> I have a GridView in my pages that is very slow since I am sending all the
> data back from server and letting the GridView handle the paging.
>
> I need to change that since in one of my projects I could have a couple
> thousand rows sent back.
>
> Where does the GridView put the data when it is doing the paging?
>
> Does it call the Sql Server each time it pages it?
>
> I am planning to change the code so that the paging is done on the server.
> My Sql would look something like:
>
> With PagedResults AS
> (
> SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
> OVER (ORDER BY LastName, FirstName) AS ResultSetRowNumber
> FROM HumanResources.vEmployee
> )
> SELECT *
> FROM PagedResults
> WHERE ResultSetRowNumber > 40 AND ResultSetRowNumber <= 50
>
> Where the Order By and row number would be dynamic.
>
> Would I have to set this up as a dynamic SQL to accomplish this?
>
> Or could I do something like:
>
> With PagedResults AS
> (
> SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
> OVER (ORDER BY @SortColumns) AS ResultSetRowNumber
> FROM HumanResources.vEmployee
> )
> SELECT *
> FROM PagedResults
> WHERE ResultSetRowNumber > @StartRow AND ResultSetRowNumber <= @EndRow
>
> Thanks,
>
> Tom
>
>

 
Reply With Quote
 
 
 
 
Mr. Arnold
Guest
Posts: n/a
 
      02-04-2010
tshad wrote:
> I have a GridView in my pages that is very slow since I am sending all the
> data back from server and letting the GridView handle the paging.
>
> I need to change that since in one of my projects I could have a couple
> thousand rows sent back.
>
> Where does the GridView put the data when it is doing the paging?
>
> Does it call the Sql Server each time it pages it?


I would control the loading of the Gridview on subsets of data being
returned, like Lastname starts with "A" with a Like statement. Starting
with Lastname starts with "A" would be the first subset seen by the
user. They would be given a TextBox they would use to give "B" or "C" or
"T".

You give the illusion of speed, by not bringing back all the data, only
subsets.
 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      02-04-2010
On Feb 4, 1:33*am, "tshad" <t...@dslextreme.com> wrote:
> I have a GridView in my pages that is very slow since I am sending all the
> data back from server and letting the GridView handle the paging.
>
> I need to change that since in one of my projects I could have a couple
> thousand rows sent back.
>
> Where does the GridView put the data when it is doing the paging?
>
> Does it call the Sql Server each time it pages it?
>
> I am planning to change the code so that the paging is done on the server..
> My Sql would look something like:
>
> With PagedResults AS
> (
> *SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
> OVER (ORDER BY LastName, FirstName) AS ResultSetRowNumber
> *FROM HumanResources.vEmployee
> )
> SELECT *
> FROM PagedResults
> WHERE ResultSetRowNumber > 40 AND ResultSetRowNumber <= 50
>
> Where the Order By and row number would be dynamic.
>
> Would I have to set this up as a dynamic SQL to accomplish this?
>
> Or could I do something like:
>
> With PagedResults AS
> (
> *SELECT EmployeeId, FirstName, MiddleName, LastName, JobTitle, ROW_NUMBER()
> OVER (ORDER BY @SortColumns) AS ResultSetRowNumber
> *FROM HumanResources.vEmployee
> )
> SELECT *
> FROM PagedResults
> WHERE ResultSetRowNumber > @StartRow AND ResultSetRowNumber <= @EndRow
>
> Thanks,
>
> Tom


I think it makes sense to do a custom paging with only records you
need to show on the current page (like you told above). In many cases
user will not go to the next page, so why to return more than he want
to see?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Hierarchical View - Gridview in Gridview =?Utf-8?B?bWdvbnphbGVzMw==?= ASP .Net 1 05-09-2006 06:48 PM
[ot]Valid excuse for speeding? JaR MCSE 9 01-05-2005 08:23 PM
speeding up data transfer? Devin Panchal Wireless Networking 1 09-06-2004 05:46 PM
Need some hints on speeding up Spamtrap Perl 1 08-11-2004 11:25 PM
Speeding up page display Troy ASP .Net 2 01-22-2004 09:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57