当前位置: 代码迷 >> ASP >> 请教各位这个SQL语句该怎么优化呢
  详细解决方案

请教各位这个SQL语句该怎么优化呢

热度:322   发布时间:2013-08-10 21:14:06.0
请问各位这个SQL语句该如何优化呢?
都是一个表里的数据,而且都是重复的语句,这些语句的作用就是从表里取出的数据,按照不同的值,赋值到不同的变量上。但是我写的这些SQL语句,造成页面读的时候特别慢。所以想优化一下这些SQL语句。请各位高手指点。


<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 1 and status = 0 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_ats = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 1 and status = 1 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_bts = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 2 and status = 0 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_atsxf = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 2 and status = 1 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_btsxf = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 3 and status = 0 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_atszj = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 3 and status = 1 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.open sql,conn,0,1 
jishu_btszj = RS.RecordCount 'totalrec:总记录条数 
%>
<%
set rs = server.createobject("adodb.recordset")
sql = "select * from pz where vision = 4 and status = 0 order by id desc"
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.Open sql,conn,1,3
  相关解决方案