查询优化代码(分别查询前几条,之后的几条,再后面的几条)

庄子 2009-05-16 10:37:30
我要分别查询前4条, 4-8条, 8-12条, 12-16,16-20
我用的是下面的查询过程, 但是这个在我网页里, 当出现过两次以后, 查询速度就会一下子变的奇慢无比, 有谁能帮我优化下吗
<%call Qylist(4,"""",15)%>,<%call Qylist(4,4,15)%>,<%call Qylist(4,8,15)%>,
<%
'*************************************************
'函数名:qylist 企业黄页列表(首页)
'作 用:显示企业列表
'参 数:
' top ------显示行数
' strlen ----截取长度
'返回值:截取后的字符串
'*************************************************
sub qylist(top,pretop,strlen)
sql="select top "&top&" ID,Qymc,url from Corporation where cFlag=1 and Uflag =1 and huangye =1"
if pretop <> """" then
sql=sql&" and ID not in (select top "&pretop&" ID from Corporation where cFlag=1 and Uflag =1 and huangye =1 order by ID desc)"
end if
sql = sql &" order by ID desc"
' response.Write(sql)
rs.open sql,conn,1,1
if not rs.eof and not rs.bof then
do while not rs.eof
id =rs("ID")
qytitle = rs("Qymc")
url = rs("url")

%>
<li><% if IsNull(url)=False then%><a href="/<%=url%>" target="_blank"><%else%><a href="/company/1/index.asp?GsID=<%=id%>" target="_blank"><%end if%><%=gotTopic(qytitle,strlen)%></a></li>
<%
rs.movenext
loop
end if
rs.close
end sub
%>
...全文
56 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Snooke 2009-05-17
  • 打赏
  • 举报
回复
建议把查询参数与其它一些条件去掉...
APOLLO_TS 2009-05-17
  • 打赏
  • 举报
回复
你这是什么数据库呀!

使用物理分页不就行了!!

从CODE上看,这样的企业黄页重新开发吧。

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧