Web| Program | performance | page
I have such a small program: ASP + sqlserver2000.
The amount of data increased very quickly, recently found that its performance is very poor, every time it takes more than 10 seconds, or even dozens of seconds, because I
The program pagination is in my own paging program:
Does this paging program have problems, but other places to use it did not feel slow ah, I'm okay to think about him, to the Internet to check the data, the results did not specifically find out about my poor performance of the paging program related information, and then I found that the pager in my program with the digital navigation method, and all the page navigation numbers are out, altogether more than 1000 pages, can make this place slow? I decided to test it, so I just let him output the first 200 pages of the navigation link, the result 1 seconds on the brush out. It dawned on me that the output was too much. Previously encountered performance problems will go to the database operation, never think of other places will have problems, or rarely think of other places. In fact, the page output data volume on the performance is also a great impact, so we must develop a good habit of writing procedures, and strive for simplicity.
Then I optimized the program, the optimization two steps, the first step I do not have all the navigation, output only the first 200 pages, followed by a text box for navigation.
At the same time I have simplified each link, which has a long link, so I put the link in the JavaScript function, and then navigate the number with only one onclick event. This reduces a lot of output data. The result is very good performance.
The original code fragment:
<font color= "#008080" size= "2" > Current <font color=ff0000>
<%=tCurPage%></font> Page Total <font color=ff0000>
<%=tpagecount%></font> page
<br><% if Ttotalcount>0 Then
For I=1 to Tpagecount
%><a href= ' <%=request.servervariables ("Path_info")%>
?page=<%=i%>&browsersize=<%=browsersize%>
&t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>
&order_dir=<%=tOrderDirection%>&oType=<%=oType%>
&OOP=<%=OOP%>&OKEY=<%=FILTERPARAM4 (Okey)%>
&page_size=<%=tPageSize%><%=add_Option%> ' ><%=i%></a>
<% if Browsersize=1 Then
If i=20 or i=36 then Response.Write ""
End If
If I=fcou Then
Exit For
End If
Response.Write ""
Next%>
<%dim Allstr
If Tpagecount>fcou Then
For I=fcou+1 to Tpagecount
If Browsersize=0 Then
m= (i=74 or i=107 or (i>107 and (i-107) mod 27) =0))
Else
m= (i=94 or i=130 or (i>130 and (i-130) mod 35) =0))
End If
Allstr=allstr & "<a href= '" &request.servervariables ("Path_info") & "?
Page= "&i&" &browsersize= "&browserSize&" &t_count= "& Ttotalcount &
"&order_field=" & Torderfield & "&order_dir=" & Torderdirection & "&
Otype= "& Otype &" &oop= "& OOP &" &okey= "& FILTERPARAM4
(okey) & "&page_size=" & Tpagesize & Add_option &
"' >"
Allstr=allstr & I
Allstr=allstr & "</a>"
If not M then Allstr=allstr & ""
If M then Allstr=allstr & "<br>"
If Browsersize=1 Then
If i=58 or i=71 then Allstr=allstr & ""
End If
If i=106 then Allstr=allstr & ""
Next%>
<script language=javascript>
var allstr;
Allstr= "<%=allStr%>";
</script><a href= "#" title= "show more ..." Id=seemore
>
<font Color=ff0000>∨</font></a><span id=morepage></span>
<%end if%>
<% End If%> </font>
Changed code fragment:
< script language= "JavaScript" >
function MP (curpage)
{
try{
if (!curpage) return false;
var patint=/^\d+$/;
if (!patint.test (Curpage)) return false;
if (parseint (curpage) <=0) return false;
Self.location= ' <%=request.servervariables ("Path_info")%>?
Page= ' + curpage+ ' &browserSize=<%=browserSize%>
&t_count=<%=tTotalCount%>&order_field=<%=tOrderField%>
&order_dir=<%=tOrderDirection%>&oType=<%=oType%>
&OOP=<%=OOP%>&OKEY=<%=FILTERPARAM4 (Okey)%>
&page_size=<%=tPageSize%><%=add_Option%> ';
}
catch (e) {
Window.status=e.description
return false;
}
}
</script>
<font color= "#008080" size= "2" > Current <font color=ff0000>
<%=tCurPage%></font> Page Total <font color=ff0000>
<%=tpagecount%></font> page
<br><% if Ttotalcount>0 Then
For I=1 to Tpagecount
%><span ><%=i%></span>
<% if Browsersize=1 Then
If i=20 or i=36 then Response.Write ""
End If
If I=fcou Then
Exit For
End If
Response.Write ""
Next
Dim allstr
If Tpagecount>fcou Then
Showpagecount=tpagecount
If showpagecount>260 then showpagecount=260
For I=fcou+1 to Showpagecount
If Browsersize=0 Then
m= (i=74 or i=107 or (i>107 and (i-107) mod 27) =0))
Else
m= (i=94 or i=130 or (i>130 and (i-130) mod 35) =0))
End If
Allstr=allstr & "<span onclick=" MP ("& I &") ' > ' & I & ' </span> '
If not M then Allstr=allstr & ""
If M then Allstr=allstr & "<br>"
If Browsersize=1 Then
If i=58 or i=71 then Allstr=allstr & ""
End If
If i=106 then Allstr=allstr & ""
Next
Allstr=allstr & "Go to <input id=" "Spageno" "
Class= "line" "Maxlength=" "5" "
Size= "6" "> Page <span onclick= ' MP (document.getElementById (" "Spageno" "). Value) ' >GO</span> '%><a href= "#" title= "show More ..."
Id=seemore ><font color=ff0000>∨</font></a>
<span id=morepage style= "Display:none" ><%=allStr%></span>
<%end if
End If
%> </font>