DataGrid paging - a question of efficiency

Discussion in 'ASP .Net' started by Shawn, Feb 13, 2005.

  1. Shawn

    Shawn Guest

    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
    Shawn, Feb 13, 2005
    #1
    1. Advertising

  2. Shawn

    Scott M. Guest

    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" <> wrote in message
    news:...
    > 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
    >
    >
    Scott M., Feb 13, 2005
    #2
    1. Advertising

  3. Shawn

    Shawn Guest

    > 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." <> wrote in message
    news:...
    > 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" <> wrote in message
    > news:...
    > > 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
    > >
    > >

    >
    >
    Shawn, Feb 13, 2005
    #3
  4. 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
    >
    >
    >
    =?Utf-8?B?S2F1c3Rhdg==?=, Feb 13, 2005
    #4
  5. Shawn

    Shawn Guest

    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" <> wrote in message
    news:...
    > 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
    > >
    > >
    > >
    Shawn, Feb 13, 2005
    #5
  6. Shawn

    Scott Allen Guest

    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"
    <> 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
    >>
    >>
    >>
    Scott Allen, Feb 13, 2005
    #6
  7. Shawn

    Scott M. Guest

    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" <> wrote in message
    news:...
    >> 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." <> wrote in message
    > news:...
    >> 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" <> wrote in message
    >> news:...
    >> > 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
    >> >
    >> >

    >>
    >>

    >
    >
    Scott M., Feb 13, 2005
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joseph D. DeJohn

    Custom Paging Efficiency

    Joseph D. DeJohn, Aug 6, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    357
    S. Justin Gengo
    Aug 6, 2003
  2. =?Utf-8?B?UGF0cmljay5PLklnZQ==?=

    DataSet paging vs Datareader paging

    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    10,689
    Scott Allen
    Oct 8, 2004
  3. Roger
    Replies:
    0
    Views:
    963
    Roger
    Dec 28, 2004
  4. wh1974
    Replies:
    0
    Views:
    2,431
    wh1974
    Jan 12, 2005
  5. Red
    Replies:
    1
    Views:
    718
Loading...

Share This Page