By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,384 Members | 845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,384 IT Pros & Developers. It's quick & easy.

DataGrid paging - a question of efficiency

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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.

"Shawn" <bo********@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
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

Nov 19 '05 #2

P: n/a
> Why are you re-creating and re-populating the temp table on each page
request? 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

"Scott M." <s-***@nospam.nospam> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl... 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.

"Shawn" <bo********@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
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


Nov 19 '05 #3

P: n/a
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.

"Shawn" wrote:
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

Nov 19 '05 #4

P: n/a
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
"Kaustav" <Ka*****@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
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.

"Shawn" wrote:
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

Nov 19 '05 #5

P: n/a
Temp tables, derived tables - on some implementations they all boil
down to the same query plan under the covers.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sun, 13 Feb 2005 09:17:02 -0800, "Kaustav"
<Ka*****@discussions.microsoft.com> wrote:
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.

"Shawn" wrote:
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


Nov 19 '05 #6

P: n/a
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.

"Shawn" <bo********@hotmail.com> wrote in message
news:Ok**************@TK2MSFTNGP12.phx.gbl...
Why are you re-creating and re-populating the temp table on each page
request?

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

"Scott M." <s-***@nospam.nospam> wrote in message
news:OD**************@TK2MSFTNGP09.phx.gbl...
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.

"Shawn" <bo********@hotmail.com> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
> 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
>
>



Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.