请教数据库检索速度问题(急在线等。。。)

ctangqh 2005-07-09 09:42:08
我用写一个站内搜索程序为什么搜索100000条记录就好慢呢!我是就一般like 语句和%% 来实现搜索的! 为什么检索速度这么慢呢! 看看我的程序有问题吗?
有什么办法可以提高搜索速度,还有高手可不可以提供一点有名的搜索的技术核心!

<!--#include file="include/Conn.asp"-->
<%
Response.Buffer=true
If Response.IsClientConnected Then
Response.Flush
Else
Response.End
End If
%>

<%

keywords=Trim(Request("keywords"))
set rs=server.CreateObject("adodb.recordset")
sql="select Web,RegDate,Zycp,Qymc,qyjj from qyhy where Qymc like '%"&keywords&"%' order by Qymc asc"
rs.open sql,Conn,1,1



%>
<body>
<div align="center">
<p>  </p>
<table width="98%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25"> </td>
</tr>
</table>
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td>
<form action="search.asp" method="post" name="leftform" target="_parent">
<div align="center">
<INPUT name="keywords" class=ibox id="keywords" size=30>
<INPUT style="FONT-SIZE: 14px; HEIGHT: 22px" type=submit value=" 搜索">
</div>
</form>
</td>
</tr>
<tr>
<td height="10" bgcolor="#EAF4FE">共有<B><FONT color="red"><%if rs.recordcount<0 then response.write "0" else response.write (rs.recordcount) end if %>
</FONT></B>个相关结果 检索关键字<font color="#FF0000"><%=keywords%></font></td>
</tr>
<tr>
<td><%
if rs.eof and rs.bof then
response.write"<font color=red>没有找到相关信息..</font>"
else
If Request.QueryString("page")="" Or IsEmpty(Request.QueryString("page")) Then
page=1
Else
page=Cint(Request.QueryString("page"))
End If
Rs.PageSize=12
totalpage=cint(rs.recordcount/rs.pagesize)
if totalpage<(rs.recordcount/rs.pagesize) then
totalpage=totalpage+1
end if
If page>totalpage Or page<0 Then
page=1
End If

i=1
rs.Absolutepage=page
keyw=Cstr("<font color=red>"&keywords&"</font>")
set qymc=rs("qymc")
set zycp=rs("zycp")
set qyjj=rs("qyjj")
set web=rs("Web")
set begindate=rs("RegDate")
do while not rs.eof
if rs.eof or i>rs.pagesize then exit do
%>
 <table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><a href="<%Response.write(Web)%>" target="_blank"><%response.write(replace(qymc,keywords,keyw))%></a></td>
</tr>
<tr>
<td><% Response.write(replace(zycp,keywords,keyw))%></td>
</tr>
<tr>
<td><%Response.Write(replace(mid(qyjj,1,60),keywords,keyw))%>...</td>
</tr>
<tr>
<td><font color="#009900"><%Response.Write(web)%> <%Response.write(regdate)%></font></td>
</tr>
<tr>
<td height="10"></td>
</tr>
</table>
<%
i=i+1
rs.movenext
loop


%></td>
</tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25">
<%

'page=totalpage
if totalpage>1 then
for i=1 to totalpage
if ((i<=(page+5)) and (i>=(page-5))) then
if (page=i) then
response.write(" "&i&"")
else
if i=(page+5) then
response.write(" <a href=?keywords="&keywords&"&page="&i-4&"><strong>下一页</strong></a>")
elseif i=(page-5) then
response.write(" <a href=?keywords="&keywords&"&page="&i+4&"><strong>上一页</strong></a>")
else
response.write(" [<a href=?keywords="&keywords&"&page="&i&"><strong>"&i&"</strong></a>]")
end if
end if

end if
next
end if

end if
%>
</td>
</tr>
</table>

...全文
96 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
超级大笨狼 2005-07-11
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/3601/3601481.xml?temp=.2255213
lgj1012 2005-07-10
  • 打赏
  • 举报
回复
和asp 关系不大,数据库设计和查询语句没优化
andy888666 2005-07-10
  • 打赏
  • 举报
回复
给数据库必要的字段建立索引,设计数据库时最好符合三级范式!
liuyong320324 2005-07-10
  • 打赏
  • 举报
回复
学习,帮你顶
ctangqh 2005-07-10
  • 打赏
  • 举报
回复
那应该怎么优化呢!
有没有哪位高手指点一下呀!

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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