好心人帮忙看看这代码该怎么优化?
下面是某个网站的主页的[部份代码](还有很多类似的分类查询),觉得打开好慢,估计是因为执行太多的查询语句导致的。 现在使用 ASP + Access,准备把 Access 换成 SQLServer 2005。数据不够3千条记录。 1.主页绝大多数是查询同一个表,只是条件不同,能否把多条查询语句合在一起,返回多个记录集,效率是否会大大的提高呢?
2.看到网上有存存储过程可以返回多个记录集的,不知使用ASP代码是否可以返回多个记录集。
3.针对现在的代码,给点优化性能的建议。
<div class="left_tit"><span><a href="class-6.html" title="编程语言" target="_blank">更多</a></span><div style="float:left"><strong>编程语言</strong></div>
<div id="scrollDiv" class="my_croll">
<ul>
<%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 5 id,title From news Where bigclass=6 And hot='True' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("")
Else
i=0
Do While Not rs.Eof%>
<li><a href="<%=rs("id")%>.html" title="<%=rs("title")%>" target="_blank"><%=leftT(rs("title"),24)%></a></li>
<%rs.MoveNext
Loop
End If
rs.Close
Set rs=Nothing%>
</ul>
</div>
</div>
<div class="left_list">
<ul class="l_tj">
<%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 1 id,title,[desc],pic From news Where bigclass=6 And pic is not Null And flag='False' And flash = 'False' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("<li>此暂时没有信息!</li>")
Else%>
<li class="l_pic"><a href="<%=rs("id")%>.html" target="_blank" title="<%=rs("title")%>"><img src="<%=rs("pic")%>" width="118" height="80" border="0"></a></li>
<li class="l_text"><%=leftT(RemoveHTML(rs("desc")),70)%>[<a href="<%=rs("id")%>.html" target="_blank">详细</a>]</li>
<%End If
rs.Close
Set rs=Nothing%>
</ul>
<ul class="l_list">
<%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 11 id,title From news Where bigclass=6 And pic is Null And flag='False' And flash = 'False' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("<li>此暂时没有信息!</li>")
Else
i=0
Do While Not rs.Eof%>
<li>· <a href="<%=rs("id")%>.html" title="<%=rs("title")%>" target="_blank"><%=rs("title")%></a></li>
<%rs.MoveNext
Loop
End If
rs.Close
Set rs=Nothing%>
</ul>
</div>
<div class="left_tit"><span><a href="class-9.html" title="网络技术" target="_blank">更多</a></span><strong>网络技术</strong><%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 1 id,title From news Where bigclass=9 And hot='True' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("")
Else%> <label class="my_title"><a href="<%=rs("id")%>.html" target="_blank" title="<%=rs("title")%>"><%=leftT(rs("title"),24)%></a></label><%End If
rs.Close
Set rs=Nothing%>
</div>
<div class="left_list">
<ul class="l_tj">
<%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 1 id,title,[desc],pic From news Where bigclass=9 And pic is not Null And flag='False' And flash = 'False' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("<li>此暂时没有信息!</li>")
Else%>
<li class="l_pic"><a href="<%=rs("id")%>.html" target="_blank" title="<%=rs("title")%>"><img src="<%=rs("pic")%>" width="118" height="80" border="0"></a></li>
<li class="l_text"><%=leftT(RemoveHTML(rs("desc")),70)%>[<a href="<%=rs("id")%>.html" target="_blank">详细</a>]</li>
<%End If
rs.Close
Set rs=Nothing%>
</ul>
<ul class="l_list">
<%Set rs=Server.CreateObject("ADODB.RecordSet")
sql="Select Top 8 id,title From news Where bigclass=9 And pic is Null And flag='False' And flash = 'False' Order By id Desc"
rs.Open sql,conn,1,1
If rs.Eof Or rs.Bof Then
Response.Write("<li>此暂时没有信息!</li>")
Else
i=0
Do While Not rs.Eof%>
<li>· <a href="<%=rs("id")%>.html" title="<%=rs("title")%>" target="_blank"><%=rs("title")%></a></li>
<%rs.MoveNext
Loop
End If
rs.Close
Set rs=Nothing%>
</ul>
</div>