asp+sql server2000,有一张企业表,8万条数据,目前显示感觉特别慢。
表结构设计如下:
ID 主键,自增长
CorpName char(150)
UserName char(50)
.....以及其它列目前不带条件的显示都慢,分页50条。
select corpname from table1两个问题:
1、是否索引不合理的问题?我没有建索引
2、分页方式不合理?
'转到指定的页数
for intCount = 1 to intStartPos
if rs.Eof then
Exit For
end if
rs.MoveNext
next intShowCount = vbNoPerPage
if intStartPos + vbNoPerPage >= rs.RecordCount then
intShowCount = rs.RecordCount - intStartPos
blNoNextPage = true
end if '显示纪录
for intCount = 1 to intShowCount
表结构设计如下:
ID 主键,自增长
CorpName char(150)
UserName char(50)
.....以及其它列目前不带条件的显示都慢,分页50条。
select corpname from table1两个问题:
1、是否索引不合理的问题?我没有建索引
2、分页方式不合理?
'转到指定的页数
for intCount = 1 to intStartPos
if rs.Eof then
Exit For
end if
rs.MoveNext
next intShowCount = vbNoPerPage
if intStartPos + vbNoPerPage >= rs.RecordCount then
intShowCount = rs.RecordCount - intStartPos
blNoNextPage = true
end if '显示纪录
for intCount = 1 to intShowCount
select corpname from table1没有WHERE条件无法使用索引分页的部分不清楚
rs.Open strSql,Conn,1,3for intCount = 1 to intStartPos
if rs.Eof then
Exit For
end if
rs.MoveNext
next intShowCount = vbNoPerPage
if intStartPos + vbNoPerPage >= rs.RecordCount then
intShowCount = rs.RecordCount - intStartPos
blNoNextPage = true
end if '显示纪录
for intCount = 1 to intShowCount显示数据的表格(省略)rs.MoveNext
next共有<% = rs.RecordCount %>条记录
<%PageCount=Round(rs.RecordCount/vbNoPerPage+0.5)%>
<%
if intNowPage > 1 then
strHref = "?Page=" & (intNowPage - 1)&""
%>
<a href=<% = strHref %>>上一页</a>
<%
else
Response.Write "<font color=#666666>上一页</font>"
end if
if not blNoNextPage then
strHref = "?Page=" & (intNowPage + 1) &""
%>
<a href=<% = strHref %>>下一页</a>
<%
else
Response.Write "<font color=#666666>下一页</font>"
end if
%>
2)所有数据都取到程序里再分页?
是否可以考虑把分页放到数据库来做 每次只传输分页的数据
strSql = "select corpname from table1 where id>0 "
if ss>0 then
strSql = strSql & " and status<>4"
end if
if dd>0 then
strSql = strSql & " and status=4"
end if
end ifstrSql = strSql & "order by id desc"
2、一次性查出8W行数据,代表你的程序设计有问题。