DataGrid paging - a question of efficiency

S

Shawn

Hi.

I already have a datagrid where I'm using paging. I have a stored procedure
that fills a temp table with 200-500 rows and then sends back 10 records at
the time. When I go to page 2 the SP fills the temp table again and returns
rows 10-19. The temp table is dropped after each call to the SP, so it has
to be created and filled every time the user changes page in the datagrid.
My question is this: Would it be more efficient to return all rows to the
datagrid and set the visibility on each datagriditem instead? After the
datagrid is filled up I could hide all but the 10 first datagrid items, and
when the user changes to page 2 I could set only datagrid items 10-19
visible etc. I have read quite a lot about custom paging, but I have never
read anything about this approach therefore I'm interested in what you
experts have to say. Is it a good idea?



Thanks,

Shawn
 
S

Scott M.

Why are you re-creating and re-populating the temp table on each page
request? Why not store this data in ViewState or the Cache or some other
medium? The only time you should be going back to the database is on the
first page load unless you want to use custom paging and you are going to
the db on each page call, but only bringing down 1 page worth of data.
 
S

Shawn

Why are you re-creating and re-populating the temp table on each page
The temp table is created by my stored procedure. When the stored procedure
has finished all temp tables cerated by that SP are automatically dropped by
sybase.
Why not store this data in ViewState or the Cache or some other
medium?
Thats exactly what I'm considering. Return all rows from the SP (not just
10 and 10), fill the datagrid with all of them, but only show 10 rows at the
time. That way all rows would all be stored in ViewState.
The only time you should be going back to the database is on the
first page load unless you want to use custom paging and you are going to
the db on each page call, but only bringing down 1 page worth of data.
Didn't you read what I wrote? I am using custom paging. I am returning to
the db (SP) on each page call and bringing back 1 page (10 rows) of data.

Shawn
 
G

Guest

Hi Shawn,

creating temp tables is not an ideal solution. You would be better off using
derived tables as compared to temp tables. How about specifying the number of
records to be fetched in the Fill method of the DataAdapter when you change
the page of the datagrid.

HTH.

Kaustav Neogy.
 
S

Shawn

Hi.
The thing is that I have to use temp tables. There is now way around it.
Don't ask why, just accept it :)
Anyway, specifying the number of records to be fetched in the fill method of
the dataadapter doesn't change anything. I would still have to return to
the db on each page call.

Shawn
 
S

Scott Allen

Temp tables, derived tables - on some implementations they all boil
down to the same query plan under the covers.
 
S

Scott M.

I did read what you wrote. My response was basically that you have 3
choices:

1. Bring down a copy of all the data on the first page load and store it
for subsequent page loads. The pro's of this are that you don't go to the
data source on each page call. The con is that you are bringing down all
the records but only displaying some of them.

2. Use custom paging and bring down just the records you intend to show.
The upside is that you use considerably less bandwidth. The downside is
that you have to go to the datasource on each page call.

3. Hybrid of the first 2 choices...Get a copy of all the data on the fist
page load and store it. Subsequent page calls can use custom paging against
this copy of the data to get just the records you are interested in.
Advantages here are that you just make one trip to the original data store
(freeing it up to handle other application requests), you can use page
output caching to reduce server processing as well. Downside is that you
are making a copy of the data and holding it in memory somewhere.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top