Paging article updated

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Paging article updated

    This article update was long overdue. There are now 9 different techniques:
    3 using ASP alone, and 6 using stored procedures.

    [url]http://www.aspfaq.com/2120[/url]

    Please let me know if you have any troubles with the examples.

    Aaron


    Aaron Bertrand [MVP] Guest

  2. Similar Questions and Discussions

    1. fui: swf <-> gis article
      http://www.directionsmag.com/article.php?article_id=812
    2. Updated KB Article: Publisher 2003 (834915)
      http://support.microsoft.com/default.aspx?scid=kb;en-us;834915 This article describes a Prepress problem when you print to a RIP or to a...
    3. Datagrid not updated during delete, but updated during insert and update
      Hello everyone. A test webform here, single datagrid bound to one table through dataset, and controls to delete, update and insert data. The code...
    4. Imported + updated symbols don't stay updated
      Hi everybody. I apologize for posting a question that probably any newbie should know, but ... I'm a rank Fireworks newbie. My problem is that the...
    5. [PHP] Article: PHP vs ASP
      Might want to file this link, next time somebody asks about PHP vs. ASP http://www.wowwebdesigns.com/wowbb/forum12/149.html And the thing...
  3. #2

    Default Re: Paging article updated

    Nice thanks Aaron!
    You dont have a solution for .move / getrows(chunk) available instead of
    just getrows()?
    From the discussions Ive seen here, thats quite a speedy performer too?



    "Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    news:ezdAuB11DHA.1740@TK2MSFTNGP12.phx.gbl...
    > This article update was long overdue. There are now 9 different
    techniques:
    > 3 using ASP alone, and 6 using stored procedures.
    >
    > [url]http://www.aspfaq.com/2120[/url]
    >
    > Please let me know if you have any troubles with the examples.
    >
    > Aaron
    >
    >

    grw Guest

  4. #3

    Default Re: Paging article updated

    > You dont have a solution for .move / getrows(chunk) available instead of
    > just getrows()?
    > From the discussions Ive seen here, thats quite a speedy performer too?
    Actually, it was much worse (unless I've implemented it wrong). I tried 50
    runs against each, and here were my timings.

    rsGetRows / seek
    1.625
    1.65625

    rsGetRows / move/chunk
    20.75
    20.78125

    Here is the relevant part of how I coded your suggestion:


    .... previous was the same
    if not rs.eof then
    Dim gr
    rstop = PerPage * PageNum
    rstart = rstop - (PerPage - 1)
    chunk = PerPage
    ' adjust the chunk in case we're on the last page
    if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    rs.move(rstart-1)
    gr = rs.GetRows(chunk)
    response.write "<table border=0 cellpadding=5>"
    for i = 0 to perpage - 1
    ... rest was the same

    And I used the same testing page to determine the timings, just upped from
    10 to 50 to get a more realistic sample size.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]


    Aaron Bertrand [MVP] Guest

  5. #4

    Default Re: Paging article updated


    I just spent a lot of time testing the paging script I have been
    using.

    100 records per page
    page # 50
    72000 records

    if you don't do the .move with several thousand records, it is very
    slow.

    looping twice

    with just getrows = 3.54 seconds
    with .move + getrows = .06 seconds

    I think that it is the large tables that will create issues if you do
    not use the .move method. creating an array with 72000 records may be
    the problem.

    My cp_DBConn.asp file ... with paging function

    [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]

    This script is currently being tested ... please let me know if you
    see any problems with it.





    <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    -->
    <%
    Dim theArray, thePageNum, recordsPerPage
    Dim totalPages, lastRecord

    thePage = Request.QueryString("pageNumber"): If thePage = ""
    Then thePage = "1"
    theNumRecords = 10
    sql1 = "select *from counties where state_id = 14;"

    Call cp_DBConn("open")
    theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    Call cp_DBConn("close")



    With Response
    If Not IsArray(theArray) Then '//if not array then there are
    no records
    .Write "No Records Found"
    Else
    totalPages = theArray(0,ubound(theArray,2))
    lastRecord = ubound(theArray,2) - 1 '//last record is
    just recordcount
    lastColumn = ubound(theArray,1)
    For n = 0 to lastRecord
    For i = 0 to lastColumn
    .Write theArray(i,n)
    If Not i = lastColumn Then: .Write "
    -- ": End If
    Next
    .Write "<br />"
    Next
    .Write "<br />"
    For n = 1 to totalPages
    .Write " <a href=""?pageNumber=" & n & """
    style=""color: blue;"""
    If CInt(thePage) = CInt(n) Then: .Write "
    style=""font-weight: bold; font-size: 20pt;""": End If
    .Write ">" & n & "</a> || "
    Next
    End If
    End With
    %>


















    On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    <aaron@TRASHaspfaq.com> wrote:
    >> You dont have a solution for .move / getrows(chunk) available instead of
    >> just getrows()?
    >> From the discussions Ive seen here, thats quite a speedy performer too?
    >
    >Actually, it was much worse (unless I've implemented it wrong). I tried 50
    >runs against each, and here were my timings.
    >
    >rsGetRows / seek
    > 1.625
    > 1.65625
    >
    >rsGetRows / move/chunk
    > 20.75
    > 20.78125
    >
    >Here is the relevant part of how I coded your suggestion:
    >
    >
    >... previous was the same
    >if not rs.eof then
    > Dim gr
    > rstop = PerPage * PageNum
    > rstart = rstop - (PerPage - 1)
    > chunk = PerPage
    > ' adjust the chunk in case we're on the last page
    > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    > rs.move(rstart-1)
    > gr = rs.GetRows(chunk)
    > response.write "<table border=0 cellpadding=5>"
    > for i = 0 to perpage - 1
    > ... rest was the same
    >
    >And I used the same testing page to determine the timings, just upped from
    >10 to 50 to get a more realistic sample size.
    >
    >--
    >Aaron Bertrand
    >SQL Server MVP
    >[url]http://www.aspfaq.com/[/url]
    >
    >
    Brynn Guest

  6. #5

    Default Re: Paging article updated





    update ... change ....

    totalPages = theArray(0,ubound(theArray,2))

    to

    totalPages = cp_TotalPages





    On Sun, 11 Jan 2004 07:00:09 GMT, [email]z@z.com[/email] (Brynn) wrote:
    >
    >I just spent a lot of time testing the paging script I have been
    >using.
    >
    >100 records per page
    >page # 50
    >72000 records
    >
    >if you don't do the .move with several thousand records, it is very
    >slow.
    >
    >looping twice
    >
    >with just getrows = 3.54 seconds
    >with .move + getrows = .06 seconds
    >
    >I think that it is the large tables that will create issues if you do
    >not use the .move method. creating an array with 72000 records may be
    >the problem.
    >
    >My cp_DBConn.asp file ... with paging function
    >
    >[url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    >This script is currently being tested ... please let me know if you
    >see any problems with it.
    >
    >
    >
    >
    >
    ><!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >-->
    ><%
    >Dim theArray, thePageNum, recordsPerPage
    >Dim totalPages, lastRecord
    >
    > thePage = Request.QueryString("pageNumber"): If thePage = ""
    >Then thePage = "1"
    > theNumRecords = 10
    > sql1 = "select *from counties where state_id = 14;"
    >
    > Call cp_DBConn("open")
    > theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    > Call cp_DBConn("close")
    >
    >
    >
    >With Response
    > If Not IsArray(theArray) Then '//if not array then there are
    >no records
    > .Write "No Records Found"
    > Else
    > totalPages = theArray(0,ubound(theArray,2))
    > lastRecord = ubound(theArray,2) - 1 '//last record is
    >just recordcount
    > lastColumn = ubound(theArray,1)
    > For n = 0 to lastRecord
    > For i = 0 to lastColumn
    > .Write theArray(i,n)
    > If Not i = lastColumn Then: .Write "
    >-- ": End If
    > Next
    > .Write "<br />"
    > Next
    > .Write "<br />"
    > For n = 1 to totalPages
    > .Write " <a href=""?pageNumber=" & n & """
    >style=""color: blue;"""
    > If CInt(thePage) = CInt(n) Then: .Write "
    >style=""font-weight: bold; font-size: 20pt;""": End If
    > .Write ">" & n & "</a> || "
    > Next
    > End If
    >End With
    >%>
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    ><aaron@TRASHaspfaq.com> wrote:
    >
    >>> You dont have a solution for .move / getrows(chunk) available instead of
    >>> just getrows()?
    >>> From the discussions Ive seen here, thats quite a speedy performer too?
    >>
    >>Actually, it was much worse (unless I've implemented it wrong). I tried 50
    >>runs against each, and here were my timings.
    >>
    >>rsGetRows / seek
    >> 1.625
    >> 1.65625
    >>
    >>rsGetRows / move/chunk
    >> 20.75
    >> 20.78125
    >>
    >>Here is the relevant part of how I coded your suggestion:
    >>
    >>
    >>... previous was the same
    >>if not rs.eof then
    >> Dim gr
    >> rstop = PerPage * PageNum
    >> rstart = rstop - (PerPage - 1)
    >> chunk = PerPage
    >> ' adjust the chunk in case we're on the last page
    >> if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >> rs.move(rstart-1)
    >> gr = rs.GetRows(chunk)
    >> response.write "<table border=0 cellpadding=5>"
    >> for i = 0 to perpage - 1
    >> ... rest was the same
    >>
    >>And I used the same testing page to determine the timings, just upped from
    >>10 to 50 to get a more realistic sample size.
    >>
    >>--
    >>Aaron Bertrand
    >>SQL Server MVP
    >>[url]http://www.aspfaq.com/[/url]
    >>
    >>
    >
    Brynn Guest

  7. #6

    Default Re: Paging article updated

    I have no way to judge what's going on. You didn't include the cp_
    functions, like cp_DBPaging.

    --
    Aaron Bertrand
    SQL Server MVP
    [url]http://www.aspfaq.com/[/url]




    "Brynn" <z@z.com> wrote in message
    news:4000dbd2.22406338@news.comcast.giganews.com.. .
    >
    > I just spent a lot of time testing the paging script I have been
    > using.
    >
    > 100 records per page
    > page # 50
    > 72000 records
    >
    > if you don't do the .move with several thousand records, it is very
    > slow.
    >
    > looping twice
    >
    > with just getrows = 3.54 seconds
    > with .move + getrows = .06 seconds
    >
    > I think that it is the large tables that will create issues if you do
    > not use the .move method. creating an array with 72000 records may be
    > the problem.
    >
    > My cp_DBConn.asp file ... with paging function
    >
    > [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    > This script is currently being tested ... please let me know if you
    > see any problems with it.
    >
    >
    >
    >
    >
    > <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    > -->
    > <%
    > Dim theArray, thePageNum, recordsPerPage
    > Dim totalPages, lastRecord
    >
    > thePage = Request.QueryString("pageNumber"): If thePage = ""
    > Then thePage = "1"
    > theNumRecords = 10
    > sql1 = "select *from counties where state_id = 14;"
    >
    > Call cp_DBConn("open")
    > theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    > Call cp_DBConn("close")
    >
    >
    >
    > With Response
    > If Not IsArray(theArray) Then '//if not array then there are
    > no records
    > .Write "No Records Found"
    > Else
    > totalPages = theArray(0,ubound(theArray,2))
    > lastRecord = ubound(theArray,2) - 1 '//last record is
    > just recordcount
    > lastColumn = ubound(theArray,1)
    > For n = 0 to lastRecord
    > For i = 0 to lastColumn
    > .Write theArray(i,n)
    > If Not i = lastColumn Then: .Write "
    > -- ": End If
    > Next
    > .Write "<br />"
    > Next
    > .Write "<br />"
    > For n = 1 to totalPages
    > .Write " <a href=""?pageNumber=" & n & """
    > style=""color: blue;"""
    > If CInt(thePage) = CInt(n) Then: .Write "
    > style=""font-weight: bold; font-size: 20pt;""": End If
    > .Write ">" & n & "</a> || "
    > Next
    > End If
    > End With
    > %>
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    > <aaron@TRASHaspfaq.com> wrote:
    >
    > >> You dont have a solution for .move / getrows(chunk) available instead
    of
    > >> just getrows()?
    > >> From the discussions Ive seen here, thats quite a speedy performer too?
    > >
    > >Actually, it was much worse (unless I've implemented it wrong). I tried
    50
    > >runs against each, and here were my timings.
    > >
    > >rsGetRows / seek
    > > 1.625
    > > 1.65625
    > >
    > >rsGetRows / move/chunk
    > > 20.75
    > > 20.78125
    > >
    > >Here is the relevant part of how I coded your suggestion:
    > >
    > >
    > >... previous was the same
    > >if not rs.eof then
    > > Dim gr
    > > rstop = PerPage * PageNum
    > > rstart = rstop - (PerPage - 1)
    > > chunk = PerPage
    > > ' adjust the chunk in case we're on the last page
    > > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    > > rs.move(rstart-1)
    > > gr = rs.GetRows(chunk)
    > > response.write "<table border=0 cellpadding=5>"
    > > for i = 0 to perpage - 1
    > > ... rest was the same
    > >
    > >And I used the same testing page to determine the timings, just upped
    from
    > >10 to 50 to get a more realistic sample size.
    > >
    > >--
    > >Aaron Bertrand
    > >SQL Server MVP
    > >[url]http://www.aspfaq.com/[/url]
    > >
    > >
    >

    Aaron Bertrand [MVP] Guest

  8. #7

    Default Re: Paging article updated

    Also...

    lastRecord = ubound(theArray,2) - 1

    to...

    lastRecord = ubound(theArray,2)


    On Sun, 11 Jan 2004 07:00:09 GMT, [email]z@z.com[/email] (Brynn) wrote:
    >
    >I just spent a lot of time testing the paging script I have been
    >using.
    >
    >100 records per page
    >page # 50
    >72000 records
    >
    >if you don't do the .move with several thousand records, it is very
    >slow.
    >
    >looping twice
    >
    >with just getrows = 3.54 seconds
    >with .move + getrows = .06 seconds
    >
    >I think that it is the large tables that will create issues if you do
    >not use the .move method. creating an array with 72000 records may be
    >the problem.
    >
    >My cp_DBConn.asp file ... with paging function
    >
    >[url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    >This script is currently being tested ... please let me know if you
    >see any problems with it.
    >
    >
    >
    >
    >
    ><!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >-->
    ><%
    >Dim theArray, thePageNum, recordsPerPage
    >Dim totalPages, lastRecord
    >
    > thePage = Request.QueryString("pageNumber"): If thePage = ""
    >Then thePage = "1"
    > theNumRecords = 10
    > sql1 = "select *from counties where state_id = 14;"
    >
    > Call cp_DBConn("open")
    > theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    > Call cp_DBConn("close")
    >
    >
    >
    >With Response
    > If Not IsArray(theArray) Then '//if not array then there are
    >no records
    > .Write "No Records Found"
    > Else
    > totalPages = theArray(0,ubound(theArray,2))
    > lastRecord = ubound(theArray,2) - 1 '//last record is
    >just recordcount
    > lastColumn = ubound(theArray,1)
    > For n = 0 to lastRecord
    > For i = 0 to lastColumn
    > .Write theArray(i,n)
    > If Not i = lastColumn Then: .Write "
    >-- ": End If
    > Next
    > .Write "<br />"
    > Next
    > .Write "<br />"
    > For n = 1 to totalPages
    > .Write " <a href=""?pageNumber=" & n & """
    >style=""color: blue;"""
    > If CInt(thePage) = CInt(n) Then: .Write "
    >style=""font-weight: bold; font-size: 20pt;""": End If
    > .Write ">" & n & "</a> || "
    > Next
    > End If
    >End With
    >%>
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    ><aaron@TRASHaspfaq.com> wrote:
    >
    >>> You dont have a solution for .move / getrows(chunk) available instead of
    >>> just getrows()?
    >>> From the discussions Ive seen here, thats quite a speedy performer too?
    >>
    >>Actually, it was much worse (unless I've implemented it wrong). I tried 50
    >>runs against each, and here were my timings.
    >>
    >>rsGetRows / seek
    >> 1.625
    >> 1.65625
    >>
    >>rsGetRows / move/chunk
    >> 20.75
    >> 20.78125
    >>
    >>Here is the relevant part of how I coded your suggestion:
    >>
    >>
    >>... previous was the same
    >>if not rs.eof then
    >> Dim gr
    >> rstop = PerPage * PageNum
    >> rstart = rstop - (PerPage - 1)
    >> chunk = PerPage
    >> ' adjust the chunk in case we're on the last page
    >> if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >> rs.move(rstart-1)
    >> gr = rs.GetRows(chunk)
    >> response.write "<table border=0 cellpadding=5>"
    >> for i = 0 to perpage - 1
    >> ... rest was the same
    >>
    >>And I used the same testing page to determine the timings, just upped from
    >>10 to 50 to get a more realistic sample size.
    >>
    >>--
    >>Aaron Bertrand
    >>SQL Server MVP
    >>[url]http://www.aspfaq.com/[/url]
    >>
    >>
    >
    Brynn Guest

  9. #8

    Default Re: Paging article updated


    I haven't done really extensive testing ... my code is just using the
    popular method of .move and getrows ... i have been using this method
    from way back when asp101.com first put their article up on getrows.

    Anyway, the code I use can be seen, copied, whatever at

    [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]

    but it is just the
    rs.move(pageNumber * recsPerPage) - recsPerPage
    myArray = rs.GetRows(recsPerPage)

    When using it with 72000 records, it seemed to work better. I could be
    doing something wrong in my testing ... not sure. It was against a
    database of all us zips, cities, couties, states that I have

    I doubt a person will end up with 72000 records after they execute
    their SQL statement .... but forums and threads can get pretty long
    ... so can customer databases I guess ... so maybe.

    I truly respect your opinions and wisdom, and look forward to your
    reply. Just tryin to do the best I can :)

    Brynn
    [url]www.coolpier.com[/url]





    On Sun, 11 Jan 2004 09:41:12 -0500, "Aaron Bertrand [MVP]"
    <aaron@TRASHaspfaq.com> wrote:
    >I have no way to judge what's going on. You didn't include the cp_
    >functions, like cp_DBPaging.
    >
    >--
    >Aaron Bertrand
    >SQL Server MVP
    >[url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    >"Brynn" <z@z.com> wrote in message
    >news:4000dbd2.22406338@news.comcast.giganews.com. ..
    >>
    >> I just spent a lot of time testing the paging script I have been
    >> using.
    >>
    >> 100 records per page
    >> page # 50
    >> 72000 records
    >>
    >> if you don't do the .move with several thousand records, it is very
    >> slow.
    >>
    >> looping twice
    >>
    >> with just getrows = 3.54 seconds
    >> with .move + getrows = .06 seconds
    >>
    >> I think that it is the large tables that will create issues if you do
    >> not use the .move method. creating an array with 72000 records may be
    >> the problem.
    >>
    >> My cp_DBConn.asp file ... with paging function
    >>
    >> [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >>
    >> This script is currently being tested ... please let me know if you
    >> see any problems with it.
    >>
    >>
    >>
    >>
    >>
    >> <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >> -->
    >> <%
    >> Dim theArray, thePageNum, recordsPerPage
    >> Dim totalPages, lastRecord
    >>
    >> thePage = Request.QueryString("pageNumber"): If thePage = ""
    >> Then thePage = "1"
    >> theNumRecords = 10
    >> sql1 = "select *from counties where state_id = 14;"
    >>
    >> Call cp_DBConn("open")
    >> theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    >> Call cp_DBConn("close")
    >>
    >>
    >>
    >> With Response
    >> If Not IsArray(theArray) Then '//if not array then there are
    >> no records
    >> .Write "No Records Found"
    >> Else
    >> totalPages = theArray(0,ubound(theArray,2))
    >> lastRecord = ubound(theArray,2) - 1 '//last record is
    >> just recordcount
    >> lastColumn = ubound(theArray,1)
    >> For n = 0 to lastRecord
    >> For i = 0 to lastColumn
    >> .Write theArray(i,n)
    >> If Not i = lastColumn Then: .Write "
    >> -- ": End If
    >> Next
    >> .Write "<br />"
    >> Next
    >> .Write "<br />"
    >> For n = 1 to totalPages
    >> .Write " <a href=""?pageNumber=" & n & """
    >> style=""color: blue;"""
    >> If CInt(thePage) = CInt(n) Then: .Write "
    >> style=""font-weight: bold; font-size: 20pt;""": End If
    >> .Write ">" & n & "</a> || "
    >> Next
    >> End If
    >> End With
    >> %>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >> On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    >> <aaron@TRASHaspfaq.com> wrote:
    >>
    >> >> You dont have a solution for .move / getrows(chunk) available instead
    >of
    >> >> just getrows()?
    >> >> From the discussions Ive seen here, thats quite a speedy performer too?
    >> >
    >> >Actually, it was much worse (unless I've implemented it wrong). I tried
    >50
    >> >runs against each, and here were my timings.
    >> >
    >> >rsGetRows / seek
    >> > 1.625
    >> > 1.65625
    >> >
    >> >rsGetRows / move/chunk
    >> > 20.75
    >> > 20.78125
    >> >
    >> >Here is the relevant part of how I coded your suggestion:
    >> >
    >> >
    >> >... previous was the same
    >> >if not rs.eof then
    >> > Dim gr
    >> > rstop = PerPage * PageNum
    >> > rstart = rstop - (PerPage - 1)
    >> > chunk = PerPage
    >> > ' adjust the chunk in case we're on the last page
    >> > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >> > rs.move(rstart-1)
    >> > gr = rs.GetRows(chunk)
    >> > response.write "<table border=0 cellpadding=5>"
    >> > for i = 0 to perpage - 1
    >> > ... rest was the same
    >> >
    >> >And I used the same testing page to determine the timings, just upped
    >from
    >> >10 to 50 to get a more realistic sample size.
    >> >
    >> >--
    >> >Aaron Bertrand
    >> >SQL Server MVP
    >> >[url]http://www.aspfaq.com/[/url]
    >> >
    >> >
    >>
    >
    >
    Brynn Guest

  10. #9

    Default Re: Paging article updated


    P.S. I hope you can appreciate the AGE function test results in the
    general group I posted ... it shows what dates will return a bad value
    from 1/10/04 current date. And shows why a function like yours is
    required.

    :)

    Brynn



    On Sun, 11 Jan 2004 09:41:12 -0500, "Aaron Bertrand [MVP]"
    <aaron@TRASHaspfaq.com> wrote:
    >I have no way to judge what's going on. You didn't include the cp_
    >functions, like cp_DBPaging.
    >
    >--
    >Aaron Bertrand
    >SQL Server MVP
    >[url]http://www.aspfaq.com/[/url]
    >
    >
    >
    >
    >"Brynn" <z@z.com> wrote in message
    >news:4000dbd2.22406338@news.comcast.giganews.com. ..
    >>
    >> I just spent a lot of time testing the paging script I have been
    >> using.
    >>
    >> 100 records per page
    >> page # 50
    >> 72000 records
    >>
    >> if you don't do the .move with several thousand records, it is very
    >> slow.
    >>
    >> looping twice
    >>
    >> with just getrows = 3.54 seconds
    >> with .move + getrows = .06 seconds
    >>
    >> I think that it is the large tables that will create issues if you do
    >> not use the .move method. creating an array with 72000 records may be
    >> the problem.
    >>
    >> My cp_DBConn.asp file ... with paging function
    >>
    >> [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >>
    >> This script is currently being tested ... please let me know if you
    >> see any problems with it.
    >>
    >>
    >>
    >>
    >>
    >> <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >> -->
    >> <%
    >> Dim theArray, thePageNum, recordsPerPage
    >> Dim totalPages, lastRecord
    >>
    >> thePage = Request.QueryString("pageNumber"): If thePage = ""
    >> Then thePage = "1"
    >> theNumRecords = 10
    >> sql1 = "select *from counties where state_id = 14;"
    >>
    >> Call cp_DBConn("open")
    >> theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    >> Call cp_DBConn("close")
    >>
    >>
    >>
    >> With Response
    >> If Not IsArray(theArray) Then '//if not array then there are
    >> no records
    >> .Write "No Records Found"
    >> Else
    >> totalPages = theArray(0,ubound(theArray,2))
    >> lastRecord = ubound(theArray,2) - 1 '//last record is
    >> just recordcount
    >> lastColumn = ubound(theArray,1)
    >> For n = 0 to lastRecord
    >> For i = 0 to lastColumn
    >> .Write theArray(i,n)
    >> If Not i = lastColumn Then: .Write "
    >> -- ": End If
    >> Next
    >> .Write "<br />"
    >> Next
    >> .Write "<br />"
    >> For n = 1 to totalPages
    >> .Write " <a href=""?pageNumber=" & n & """
    >> style=""color: blue;"""
    >> If CInt(thePage) = CInt(n) Then: .Write "
    >> style=""font-weight: bold; font-size: 20pt;""": End If
    >> .Write ">" & n & "</a> || "
    >> Next
    >> End If
    >> End With
    >> %>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >> On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    >> <aaron@TRASHaspfaq.com> wrote:
    >>
    >> >> You dont have a solution for .move / getrows(chunk) available instead
    >of
    >> >> just getrows()?
    >> >> From the discussions Ive seen here, thats quite a speedy performer too?
    >> >
    >> >Actually, it was much worse (unless I've implemented it wrong). I tried
    >50
    >> >runs against each, and here were my timings.
    >> >
    >> >rsGetRows / seek
    >> > 1.625
    >> > 1.65625
    >> >
    >> >rsGetRows / move/chunk
    >> > 20.75
    >> > 20.78125
    >> >
    >> >Here is the relevant part of how I coded your suggestion:
    >> >
    >> >
    >> >... previous was the same
    >> >if not rs.eof then
    >> > Dim gr
    >> > rstop = PerPage * PageNum
    >> > rstart = rstop - (PerPage - 1)
    >> > chunk = PerPage
    >> > ' adjust the chunk in case we're on the last page
    >> > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >> > rs.move(rstart-1)
    >> > gr = rs.GetRows(chunk)
    >> > response.write "<table border=0 cellpadding=5>"
    >> > for i = 0 to perpage - 1
    >> > ... rest was the same
    >> >
    >> >And I used the same testing page to determine the timings, just upped
    >from
    >> >10 to 50 to get a more realistic sample size.
    >> >
    >> >--
    >> >Aaron Bertrand
    >> >SQL Server MVP
    >> >[url]http://www.aspfaq.com/[/url]
    >> >
    >> >
    >>
    >
    >
    Brynn Guest

  11. #10

    Default Re: Paging article updated

    You can use this to do the paging against a database



    <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    -->
    <%
    thePage = 2
    theNumRecords = 10

    sql1 = "select *from counties where state_id = 14;"

    Call cp_DBConn("open")
    theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    Call cp_DBConn("close")
    %>






    On Sun, 11 Jan 2004 15:31:41 GMT, [email]z@z.com[/email] (Brynn) wrote:
    >
    >I haven't done really extensive testing ... my code is just using the
    >popular method of .move and getrows ... i have been using this method
    >from way back when asp101.com first put their article up on getrows.
    >
    >Anyway, the code I use can be seen, copied, whatever at
    >
    >[url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    >but it is just the
    >rs.move(pageNumber * recsPerPage) - recsPerPage
    >myArray = rs.GetRows(recsPerPage)
    >
    >When using it with 72000 records, it seemed to work better. I could be
    >doing something wrong in my testing ... not sure. It was against a
    >database of all us zips, cities, couties, states that I have
    >
    >I doubt a person will end up with 72000 records after they execute
    >their SQL statement .... but forums and threads can get pretty long
    >.. so can customer databases I guess ... so maybe.
    >
    >I truly respect your opinions and wisdom, and look forward to your
    >reply. Just tryin to do the best I can :)
    >
    >Brynn
    >[url]www.coolpier.com[/url]
    >
    >
    >
    >
    >
    >On Sun, 11 Jan 2004 09:41:12 -0500, "Aaron Bertrand [MVP]"
    ><aaron@TRASHaspfaq.com> wrote:
    >
    >>I have no way to judge what's going on. You didn't include the cp_
    >>functions, like cp_DBPaging.
    >>
    >>--
    >>Aaron Bertrand
    >>SQL Server MVP
    >>[url]http://www.aspfaq.com/[/url]
    >>
    >>
    >>
    >>
    >>"Brynn" <z@z.com> wrote in message
    >>news:4000dbd2.22406338@news.comcast.giganews.com ...
    >>>
    >>> I just spent a lot of time testing the paging script I have been
    >>> using.
    >>>
    >>> 100 records per page
    >>> page # 50
    >>> 72000 records
    >>>
    >>> if you don't do the .move with several thousand records, it is very
    >>> slow.
    >>>
    >>> looping twice
    >>>
    >>> with just getrows = 3.54 seconds
    >>> with .move + getrows = .06 seconds
    >>>
    >>> I think that it is the large tables that will create issues if you do
    >>> not use the .move method. creating an array with 72000 records may be
    >>> the problem.
    >>>
    >>> My cp_DBConn.asp file ... with paging function
    >>>
    >>> [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >>>
    >>> This script is currently being tested ... please let me know if you
    >>> see any problems with it.
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >>> -->
    >>> <%
    >>> Dim theArray, thePageNum, recordsPerPage
    >>> Dim totalPages, lastRecord
    >>>
    >>> thePage = Request.QueryString("pageNumber"): If thePage = ""
    >>> Then thePage = "1"
    >>> theNumRecords = 10
    >>> sql1 = "select *from counties where state_id = 14;"
    >>>
    >>> Call cp_DBConn("open")
    >>> theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    >>> Call cp_DBConn("close")
    >>>
    >>>
    >>>
    >>> With Response
    >>> If Not IsArray(theArray) Then '//if not array then there are
    >>> no records
    >>> .Write "No Records Found"
    >>> Else
    >>> totalPages = theArray(0,ubound(theArray,2))
    >>> lastRecord = ubound(theArray,2) - 1 '//last record is
    >>> just recordcount
    >>> lastColumn = ubound(theArray,1)
    >>> For n = 0 to lastRecord
    >>> For i = 0 to lastColumn
    >>> .Write theArray(i,n)
    >>> If Not i = lastColumn Then: .Write "
    >>> -- ": End If
    >>> Next
    >>> .Write "<br />"
    >>> Next
    >>> .Write "<br />"
    >>> For n = 1 to totalPages
    >>> .Write " <a href=""?pageNumber=" & n & """
    >>> style=""color: blue;"""
    >>> If CInt(thePage) = CInt(n) Then: .Write "
    >>> style=""font-weight: bold; font-size: 20pt;""": End If
    >>> .Write ">" & n & "</a> || "
    >>> Next
    >>> End If
    >>> End With
    >>> %>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    >>> <aaron@TRASHaspfaq.com> wrote:
    >>>
    >>> >> You dont have a solution for .move / getrows(chunk) available instead
    >>of
    >>> >> just getrows()?
    >>> >> From the discussions Ive seen here, thats quite a speedy performer too?
    >>> >
    >>> >Actually, it was much worse (unless I've implemented it wrong). I tried
    >>50
    >>> >runs against each, and here were my timings.
    >>> >
    >>> >rsGetRows / seek
    >>> > 1.625
    >>> > 1.65625
    >>> >
    >>> >rsGetRows / move/chunk
    >>> > 20.75
    >>> > 20.78125
    >>> >
    >>> >Here is the relevant part of how I coded your suggestion:
    >>> >
    >>> >
    >>> >... previous was the same
    >>> >if not rs.eof then
    >>> > Dim gr
    >>> > rstop = PerPage * PageNum
    >>> > rstart = rstop - (PerPage - 1)
    >>> > chunk = PerPage
    >>> > ' adjust the chunk in case we're on the last page
    >>> > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >>> > rs.move(rstart-1)
    >>> > gr = rs.GetRows(chunk)
    >>> > response.write "<table border=0 cellpadding=5>"
    >>> > for i = 0 to perpage - 1
    >>> > ... rest was the same
    >>> >
    >>> >And I used the same testing page to determine the timings, just upped
    >>from
    >>> >10 to 50 to get a more realistic sample size.
    >>> >
    >>> >--
    >>> >Aaron Bertrand
    >>> >SQL Server MVP
    >>> >[url]http://www.aspfaq.com/[/url]
    >>> >
    >>> >
    >>>
    >>
    >>
    >
    Brynn Guest

  12. #11

    Default Re: Paging article updated


    ALSO, if curious ... if the recordset is EOF ... IE no records

    this is detected in the design by simply checking to see if ...

    If IsArray(theArray) Then
    '// the design for the recordset
    Else
    '// No Records Found design or redirect
    End If





    On Sun, 11 Jan 2004 15:31:41 GMT, [email]z@z.com[/email] (Brynn) wrote:
    >
    >I haven't done really extensive testing ... my code is just using the
    >popular method of .move and getrows ... i have been using this method
    >from way back when asp101.com first put their article up on getrows.
    >
    >Anyway, the code I use can be seen, copied, whatever at
    >
    >[url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    >but it is just the
    >rs.move(pageNumber * recsPerPage) - recsPerPage
    >myArray = rs.GetRows(recsPerPage)
    >
    >When using it with 72000 records, it seemed to work better. I could be
    >doing something wrong in my testing ... not sure. It was against a
    >database of all us zips, cities, couties, states that I have
    >
    >I doubt a person will end up with 72000 records after they execute
    >their SQL statement .... but forums and threads can get pretty long
    >.. so can customer databases I guess ... so maybe.
    >
    >I truly respect your opinions and wisdom, and look forward to your
    >reply. Just tryin to do the best I can :)
    >
    >Brynn
    >[url]www.coolpier.com[/url]
    >
    >
    >
    >
    >
    >On Sun, 11 Jan 2004 09:41:12 -0500, "Aaron Bertrand [MVP]"
    ><aaron@TRASHaspfaq.com> wrote:
    >
    >>I have no way to judge what's going on. You didn't include the cp_
    >>functions, like cp_DBPaging.
    >>
    >>--
    >>Aaron Bertrand
    >>SQL Server MVP
    >>[url]http://www.aspfaq.com/[/url]
    >>
    >>
    >>
    >>
    >>"Brynn" <z@z.com> wrote in message
    >>news:4000dbd2.22406338@news.comcast.giganews.com ...
    >>>
    >>> I just spent a lot of time testing the paging script I have been
    >>> using.
    >>>
    >>> 100 records per page
    >>> page # 50
    >>> 72000 records
    >>>
    >>> if you don't do the .move with several thousand records, it is very
    >>> slow.
    >>>
    >>> looping twice
    >>>
    >>> with just getrows = 3.54 seconds
    >>> with .move + getrows = .06 seconds
    >>>
    >>> I think that it is the large tables that will create issues if you do
    >>> not use the .move method. creating an array with 72000 records may be
    >>> the problem.
    >>>
    >>> My cp_DBConn.asp file ... with paging function
    >>>
    >>> [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >>>
    >>> This script is currently being tested ... please let me know if you
    >>> see any problems with it.
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >>> -->
    >>> <%
    >>> Dim theArray, thePageNum, recordsPerPage
    >>> Dim totalPages, lastRecord
    >>>
    >>> thePage = Request.QueryString("pageNumber"): If thePage = ""
    >>> Then thePage = "1"
    >>> theNumRecords = 10
    >>> sql1 = "select *from counties where state_id = 14;"
    >>>
    >>> Call cp_DBConn("open")
    >>> theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    >>> Call cp_DBConn("close")
    >>>
    >>>
    >>>
    >>> With Response
    >>> If Not IsArray(theArray) Then '//if not array then there are
    >>> no records
    >>> .Write "No Records Found"
    >>> Else
    >>> totalPages = theArray(0,ubound(theArray,2))
    >>> lastRecord = ubound(theArray,2) - 1 '//last record is
    >>> just recordcount
    >>> lastColumn = ubound(theArray,1)
    >>> For n = 0 to lastRecord
    >>> For i = 0 to lastColumn
    >>> .Write theArray(i,n)
    >>> If Not i = lastColumn Then: .Write "
    >>> -- ": End If
    >>> Next
    >>> .Write "<br />"
    >>> Next
    >>> .Write "<br />"
    >>> For n = 1 to totalPages
    >>> .Write " <a href=""?pageNumber=" & n & """
    >>> style=""color: blue;"""
    >>> If CInt(thePage) = CInt(n) Then: .Write "
    >>> style=""font-weight: bold; font-size: 20pt;""": End If
    >>> .Write ">" & n & "</a> || "
    >>> Next
    >>> End If
    >>> End With
    >>> %>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    >>> <aaron@TRASHaspfaq.com> wrote:
    >>>
    >>> >> You dont have a solution for .move / getrows(chunk) available instead
    >>of
    >>> >> just getrows()?
    >>> >> From the discussions Ive seen here, thats quite a speedy performer too?
    >>> >
    >>> >Actually, it was much worse (unless I've implemented it wrong). I tried
    >>50
    >>> >runs against each, and here were my timings.
    >>> >
    >>> >rsGetRows / seek
    >>> > 1.625
    >>> > 1.65625
    >>> >
    >>> >rsGetRows / move/chunk
    >>> > 20.75
    >>> > 20.78125
    >>> >
    >>> >Here is the relevant part of how I coded your suggestion:
    >>> >
    >>> >
    >>> >... previous was the same
    >>> >if not rs.eof then
    >>> > Dim gr
    >>> > rstop = PerPage * PageNum
    >>> > rstart = rstop - (PerPage - 1)
    >>> > chunk = PerPage
    >>> > ' adjust the chunk in case we're on the last page
    >>> > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >>> > rs.move(rstart-1)
    >>> > gr = rs.GetRows(chunk)
    >>> > response.write "<table border=0 cellpadding=5>"
    >>> > for i = 0 to perpage - 1
    >>> > ... rest was the same
    >>> >
    >>> >And I used the same testing page to determine the timings, just upped
    >>from
    >>> >10 to 50 to get a more realistic sample size.
    >>> >
    >>> >--
    >>> >Aaron Bertrand
    >>> >SQL Server MVP
    >>> >[url]http://www.aspfaq.com/[/url]
    >>> >
    >>> >
    >>>
    >>
    >>
    >
    Brynn Guest

  13. #12

    Default Re: Paging article updated


    I just ran some tests where the table is 1019732 records big ... and
    the total records with my select criteria are 28868 records.

    The paging works really fast ...

    If I comment out the .move line, and change my getrows to .getrows()
    it slows considerably.




    On Sun, 11 Jan 2004 15:31:41 GMT, [email]z@z.com[/email] (Brynn) wrote:
    >
    >I haven't done really extensive testing ... my code is just using the
    >popular method of .move and getrows ... i have been using this method
    >from way back when asp101.com first put their article up on getrows.
    >
    >Anyway, the code I use can be seen, copied, whatever at
    >
    >[url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >
    >but it is just the
    >rs.move(pageNumber * recsPerPage) - recsPerPage
    >myArray = rs.GetRows(recsPerPage)
    >
    >When using it with 72000 records, it seemed to work better. I could be
    >doing something wrong in my testing ... not sure. It was against a
    >database of all us zips, cities, couties, states that I have
    >
    >I doubt a person will end up with 72000 records after they execute
    >their SQL statement .... but forums and threads can get pretty long
    >.. so can customer databases I guess ... so maybe.
    >
    >I truly respect your opinions and wisdom, and look forward to your
    >reply. Just tryin to do the best I can :)
    >
    >Brynn
    >[url]www.coolpier.com[/url]
    >
    >
    >
    >
    >
    >On Sun, 11 Jan 2004 09:41:12 -0500, "Aaron Bertrand [MVP]"
    ><aaron@TRASHaspfaq.com> wrote:
    >
    >>I have no way to judge what's going on. You didn't include the cp_
    >>functions, like cp_DBPaging.
    >>
    >>--
    >>Aaron Bertrand
    >>SQL Server MVP
    >>[url]http://www.aspfaq.com/[/url]
    >>
    >>
    >>
    >>
    >>"Brynn" <z@z.com> wrote in message
    >>news:4000dbd2.22406338@news.comcast.giganews.com ...
    >>>
    >>> I just spent a lot of time testing the paging script I have been
    >>> using.
    >>>
    >>> 100 records per page
    >>> page # 50
    >>> 72000 records
    >>>
    >>> if you don't do the .move with several thousand records, it is very
    >>> slow.
    >>>
    >>> looping twice
    >>>
    >>> with just getrows = 3.54 seconds
    >>> with .move + getrows = .06 seconds
    >>>
    >>> I think that it is the large tables that will create issues if you do
    >>> not use the .move method. creating an array with 72000 records may be
    >>> the problem.
    >>>
    >>> My cp_DBConn.asp file ... with paging function
    >>>
    >>> [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]
    >>>
    >>> This script is currently being tested ... please let me know if you
    >>> see any problems with it.
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> <!-- #include virtual="/coolpier_scripts/_database_tools/DBConn.asp"
    >>> -->
    >>> <%
    >>> Dim theArray, thePageNum, recordsPerPage
    >>> Dim totalPages, lastRecord
    >>>
    >>> thePage = Request.QueryString("pageNumber"): If thePage = ""
    >>> Then thePage = "1"
    >>> theNumRecords = 10
    >>> sql1 = "select *from counties where state_id = 14;"
    >>>
    >>> Call cp_DBConn("open")
    >>> theArray = cp_DBPaging(sql1, thePage, theNumRecords)
    >>> Call cp_DBConn("close")
    >>>
    >>>
    >>>
    >>> With Response
    >>> If Not IsArray(theArray) Then '//if not array then there are
    >>> no records
    >>> .Write "No Records Found"
    >>> Else
    >>> totalPages = theArray(0,ubound(theArray,2))
    >>> lastRecord = ubound(theArray,2) - 1 '//last record is
    >>> just recordcount
    >>> lastColumn = ubound(theArray,1)
    >>> For n = 0 to lastRecord
    >>> For i = 0 to lastColumn
    >>> .Write theArray(i,n)
    >>> If Not i = lastColumn Then: .Write "
    >>> -- ": End If
    >>> Next
    >>> .Write "<br />"
    >>> Next
    >>> .Write "<br />"
    >>> For n = 1 to totalPages
    >>> .Write " <a href=""?pageNumber=" & n & """
    >>> style=""color: blue;"""
    >>> If CInt(thePage) = CInt(n) Then: .Write "
    >>> style=""font-weight: bold; font-size: 20pt;""": End If
    >>> .Write ">" & n & "</a> || "
    >>> Next
    >>> End If
    >>> End With
    >>> %>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>>
    >>> On Sat, 10 Jan 2004 22:46:16 -0500, "Aaron Bertrand [MVP]"
    >>> <aaron@TRASHaspfaq.com> wrote:
    >>>
    >>> >> You dont have a solution for .move / getrows(chunk) available instead
    >>of
    >>> >> just getrows()?
    >>> >> From the discussions Ive seen here, thats quite a speedy performer too?
    >>> >
    >>> >Actually, it was much worse (unless I've implemented it wrong). I tried
    >>50
    >>> >runs against each, and here were my timings.
    >>> >
    >>> >rsGetRows / seek
    >>> > 1.625
    >>> > 1.65625
    >>> >
    >>> >rsGetRows / move/chunk
    >>> > 20.75
    >>> > 20.78125
    >>> >
    >>> >Here is the relevant part of how I coded your suggestion:
    >>> >
    >>> >
    >>> >... previous was the same
    >>> >if not rs.eof then
    >>> > Dim gr
    >>> > rstop = PerPage * PageNum
    >>> > rstart = rstop - (PerPage - 1)
    >>> > chunk = PerPage
    >>> > ' adjust the chunk in case we're on the last page
    >>> > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    >>> > rs.move(rstart-1)
    >>> > gr = rs.GetRows(chunk)
    >>> > response.write "<table border=0 cellpadding=5>"
    >>> > for i = 0 to perpage - 1
    >>> > ... rest was the same
    >>> >
    >>> >And I used the same testing page to determine the timings, just upped
    >>from
    >>> >10 to 50 to get a more realistic sample size.
    >>> >
    >>> >--
    >>> >Aaron Bertrand
    >>> >SQL Server MVP
    >>> >[url]http://www.aspfaq.com/[/url]
    >>> >
    >>> >
    >>>
    >>
    >>
    >
    I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

    Brynn
    [url]www.coolpier.com[/url]
    Brynn Guest

  14. #13

    Default Re: Paging article updated


    Try out my DBConn.asp script.

    [url]http://www.coolpier.com/cp/cp_scripts/script.asp?view=code&file=DBConn.asp[/url]

    my site is under complete redesign, so bare with me. I would normally
    take it down for something like this, but want to be able to keep some
    of my content available.

    Brynn
    [url]www.coolpier.com[/url]



    On Sun, 11 Jan 2004 16:16:37 +1300, "grw" <none@none.com> wrote:
    >Nice thanks Aaron!
    >You dont have a solution for .move / getrows(chunk) available instead of
    >just getrows()?
    >From the discussions Ive seen here, thats quite a speedy performer too?
    >
    >
    >
    >"Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    >news:ezdAuB11DHA.1740@TK2MSFTNGP12.phx.gbl...
    >> This article update was long overdue. There are now 9 different
    >techniques:
    >> 3 using ASP alone, and 6 using stored procedures.
    >>
    >> [url]http://www.aspfaq.com/2120[/url]
    >>
    >> Please let me know if you have any troubles with the examples.
    >>
    >> Aaron
    >>
    >>
    >
    >
    I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

    Brynn
    [url]www.coolpier.com[/url]
    Brynn Guest

  15. #14

    Default Re: Paging article updated

    Brynn wrote:
    > I just ran some tests where the table is 1019732 records big ... and
    > the total records with my select criteria are 28868 records.
    >
    > The paging works really fast ...
    >
    > If I comment out the .move line, and change my getrows to .getrows()
    > it slows considerably.
    >
    Doesn't that make sense? When you use GetRows(), you're putting ALL the
    records into the array, aren't you? Not just the chunk you wanted ...

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  16. #15

    Default Re: Paging article updated


    I know Bob :) ... we are talking about ...

    [url]http://www.aspfaq.com/show.asp?id=2120[/url]

    the getrows method used here ...

    I am not arguing that Aaron is much better at this stuff than me ... I
    just think in the tests, he was using a smaller sized table ... so the
    array size really didn't factor in a whole lot.

    Commenting those lines in my script is similar to the results of the
    getrows method on the above aspfaq.

    Brynn

    P.S. I really do love your site Aaron :) I remember way back when,
    when it first went up :)

    On Sun, 11 Jan 2004 11:15:30 -0500, "Bob Barrows"
    <reb01501@NOyahoo.SPAMcom> wrote:
    >Brynn wrote:
    >> I just ran some tests where the table is 1019732 records big ... and
    >> the total records with my select criteria are 28868 records.
    >>
    >> The paging works really fast ...
    >>
    >> If I comment out the .move line, and change my getrows to .getrows()
    >> it slows considerably.
    >>
    >Doesn't that make sense? When you use GetRows(), you're putting ALL the
    >records into the array, aren't you? Not just the chunk you wanted ...
    >
    >Bob Barrows
    >--
    >Microsoft MVP - ASP/ASP.NET
    >Please reply to the newsgroup. This email account is my spam trap so I
    >don't check it very often. If you must reply off-line, then remove the
    >"NO SPAM"
    >
    >
    I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

    Brynn
    [url]www.coolpier.com[/url]
    Brynn Guest

  17. #16

    Default Re: Paging article updated

    Brynn wrote:
    > I know Bob :) ... we are talking about ...
    >
    > [url]http://www.aspfaq.com/show.asp?id=2120[/url]
    >
    > the getrows method used here ...
    >
    Well, here's what it says:
    if not rs.eof then

    Dim gr
    gr = rs.GetRows()

    rstop = PerPage * PageNum

    So this method is putting all the records into the array.
    I do not think I would do it this way. I would use AbsolutePage to move to
    the desired page, and then read only the contents of the page into the
    GetRows array.

    Bob Barrows


    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  18. #17

    Default Re: Paging article updated


    I agree that I would not do it that way. But do you think that the

    rs.AbsolutePage / GetRows(recsPerPage)

    would have an advantage over

    rs.Move(pageNum*recsPerPage) / GetRows(recsPerPage)

    in my script ... I would like to know where the benefit or difference
    comes in ... I may consider AbsolutePage instead for my own script.


    Thanks in advance for your reply Bob :)


    On Sun, 11 Jan 2004 12:37:51 -0500, "Bob Barrows"
    <reb01501@NOyahoo.SPAMcom> wrote:
    >Brynn wrote:
    >> I know Bob :) ... we are talking about ...
    >>
    >> [url]http://www.aspfaq.com/show.asp?id=2120[/url]
    >>
    >> the getrows method used here ...
    >>
    >
    >Well, here's what it says:
    >if not rs.eof then
    >
    > Dim gr
    > gr = rs.GetRows()
    >
    > rstop = PerPage * PageNum
    >
    >So this method is putting all the records into the array.
    >I do not think I would do it this way. I would use AbsolutePage to move to
    >the desired page, and then read only the contents of the page into the
    >GetRows array.
    >
    >Bob Barrows
    >
    >
    >--
    >Microsoft MVP - ASP/ASP.NET
    >Please reply to the newsgroup. This email account is my spam trap so I
    >don't check it very often. If you must reply off-line, then remove the
    >"NO SPAM"
    >
    >
    I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

    Brynn
    [url]www.coolpier.com[/url]
    Brynn Guest

  19. #18

    Default Re: Paging article updated

    Let me ammend my most recent question ... to this

    Is .AbsolutePage going to be faster (or better) versus .Move() because
    with CacheSize iw will lessen the RS load?

    Brynn



    On Sun, 11 Jan 2004 12:37:51 -0500, "Bob Barrows"
    <reb01501@NOyahoo.SPAMcom> wrote:
    >Brynn wrote:
    >> I know Bob :) ... we are talking about ...
    >>
    >> [url]http://www.aspfaq.com/show.asp?id=2120[/url]
    >>
    >> the getrows method used here ...
    >>
    >
    >Well, here's what it says:
    >if not rs.eof then
    >
    > Dim gr
    > gr = rs.GetRows()
    >
    > rstop = PerPage * PageNum
    >
    >So this method is putting all the records into the array.
    >I do not think I would do it this way. I would use AbsolutePage to move to
    >the desired page, and then read only the contents of the page into the
    >GetRows array.
    >
    >Bob Barrows
    >
    >
    >--
    >Microsoft MVP - ASP/ASP.NET
    >Please reply to the newsgroup. This email account is my spam trap so I
    >don't check it very often. If you must reply off-line, then remove the
    >"NO SPAM"
    >
    >
    I participate in the group to help give examples of code. I do not guarantee the effects of any code posted. Test all code before use!

    Brynn
    [url]www.coolpier.com[/url]
    Brynn Guest

  20. #19

    Default Re: Paging article updated

    Brynn wrote:
    > Let me ammend my most recent question ... to this
    >
    > Is .AbsolutePage going to be faster (or better) versus .Move() because
    > with CacheSize iw will lessen the RS load?
    >
    That's my thinking. I haven't tested it, but that was my thought.
    Of course, I would be doing more to limit the records being returned from
    the database in the sql statement. I've never done a paging application - I
    always prefer to give the users a way to limit the records they wish to see.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  21. #20

    Default Re: Paging article updated

    Must be my testing method, but I get twice the speed with .move
    Im not stress testing or anything, just doing a simple serverside JS timer
    function.

    However, its consistently 16 milliseconds for .move vs 50 milliseconds for
    seek
    using your script and database.

    Running a loop of 10 gives me similar results - 140ms vs 500ms

    What gives? :-)

    For reference, this is the date function
    :

    <SCRIPT LANGUAGE=JScript RUNAT=Server>
    function y2k(number) {
    return (number < 1000) ? number + 1900 : number;
    }
    function milliDif() {
    var d = new Date();
    return d.getTime()
    }

    function elapsedpretty(parm1)
    {
    var elapsedsecs = 0
    var elapsedmins = 0

    elapsedsecs=Math.floor(parm1/1000)
    parm1=parm1%1000

    elapsedmins=Math.floor(elapsedsecs/60)
    elapsedsecs=elapsedsecs%60


    elapsedpretty=elapsedmins + " minute"
    if(elapsedmins!=1)
    elapsedpretty=elapsedpretty+"s"

    elapsedpretty = elapsedpretty+" " + elapsedsecs+" second"
    if(elapsedsecs!=1)
    elapsedpretty=elapsedpretty+"s"

    elapsedpretty = elapsedpretty+ " "+parm1+" millisecond"
    if(parm1!=1)
    elapsedpretty=elapsedpretty+"s"

    return elapsedpretty;
    }
    </script>

    <%

    timeThen = milliDif()

    .....code.....

    timeNow = milliDif()

    elapsed = timeNow - timeThen
    strMsg="<br>Process time in ms: " & elapsed & "<br>" &
    elapsedpretty(elapsed)
    Response.write(strMsg) & "<br><hr>"



    "Aaron Bertrand [MVP]" <aaron@TRASHaspfaq.com> wrote in message
    news:O3gm4V$1DHA.3416@tk2msftngp13.phx.gbl...
    > > You dont have a solution for .move / getrows(chunk) available instead of
    > > just getrows()?
    > > From the discussions Ive seen here, thats quite a speedy performer too?
    >
    > Actually, it was much worse (unless I've implemented it wrong). I tried
    50
    > runs against each, and here were my timings.
    >
    > rsGetRows / seek
    > 1.625
    > 1.65625
    >
    > rsGetRows / move/chunk
    > 20.75
    > 20.78125
    >
    > Here is the relevant part of how I coded your suggestion:
    >
    >
    > ... previous was the same
    > if not rs.eof then
    > Dim gr
    > rstop = PerPage * PageNum
    > rstart = rstop - (PerPage - 1)
    > chunk = PerPage
    > ' adjust the chunk in case we're on the last page
    > if rstop > RowCnt - 1 then chunk = (RowCnt - 1) - rstart
    > rs.move(rstart-1)
    > gr = rs.GetRows(chunk)
    > response.write "<table border=0 cellpadding=5>"
    > for i = 0 to perpage - 1
    > ... rest was the same
    >
    > And I used the same testing page to determine the timings, just upped from
    > 10 to 50 to get a more realistic sample size.
    >
    > --
    > Aaron Bertrand
    > SQL Server MVP
    > [url]http://www.aspfaq.com/[/url]
    >
    >

    grw Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139