首页 新闻 会员 周边

SQL2000数据库读取慢,不知道是什么原因?

0
悬赏园豆:200 [已解决问题] 解决于 2016-05-27 20:54

如题。

表内的数据记录不到1万条,但每一次读取数据都很慢,而且我需要读取的数据也只有950条,但要完全读取及显示需要大概1分钟的时间。

可能是代码的问题,数据库没有怎么做索引。

请大家帮我查一下原因。

<!--#include file="inc/conn.asp"-->
<!--#include file="userconfig.asp"-->
<%
id=int(request("id"))
souser=request.form("souser")
pagenum=request("pagenum")

if pagenum="" or pagenum<1 then
    pagenum=1
else
    pagenum=cint(pagenum)
end if

Set rs=Server.CreateObject("ADODB.recordset")
rs.cachesize=50
rs.cursortype=1

p=request("p")
ClassId=request("ClassId")
if  isnumeric(ClassId)=false then
     ClassId=10
end if

select case p
case 1
    p="rnum"
case 2
    p="(jine+addjine)"
case else
    p="renwutime"
end select

select case ClassId
case 1
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case 2
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case 3
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case 4
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case 5
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case 6
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
case else
    mysq="select * from AdsTask_renwu where rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by "&p&" desc"
end select


rs.open mysq,conn,1,1
rs.pagesize=20
if pagenum>rs.pagecount then
pagenum=1
end if
if rs.eof then
else
rs.absolutepage=pagenum
end if
%>
<!--#include file="top.asp"-->
<%menu_t=1%>
<!--#include file="menu_style.asp"-->
<!--二级菜单-->
<div align="center">
    <table align="center" border="0" width="100%" id="table9" cellspacing="0" cellpadding="0" background="image/top_bg2.jpg" height="34">
        <tr>
            <td align="center">
                <table border="0" width="800" cellspacing="1" cellpadding="5">
                    <tr align='left'>
                                            <td width="100" align="center" class="t2 hand" background='image/t2_1_2.jpg' onClick="location.href='task.asp';">做任务赚钱</td>
                                                <td width="100" align="center" onMouseOver="this.background='image/t2_1_1.jpg';" onMouseOut="this.background='';"><a href="click.asp">点击广告赚钱</a></td>
                                                <td width="100" align="center" onMouseOver="this.background='image/t2_1_1.jpg';" onMouseOut="this.background='';"><a href="search.asp">搜索广告赚钱</a></td>
                                                <td width="100" align="center" onMouseOver="this.background='image/t2_1_1.jpg';" onMouseOut="this.background='';"><a href="profit.asp">浏览广告赚钱</a></td>                        
                        <td width="100" align="center" onMouseOver="this.background='image/t2_1_1.jpg';" onMouseOut="this.background='';"><a href="question.asp">商家问答赚钱</a></td>
                        <td width="100" align="center" onMouseOver="this.background='image/t2_1_1.jpg';" onMouseOut="this.background='';"><a href="commendcode.asp"><font color=red>推广赚钱</font></a></td>
                                                <td width="60" align="center" onMouseOver="this.background='image/t2_2_1.jpg';" onMouseOut="this.background='';"><a href="MyFavorites.asp">我的收藏</a></td>
                        <td>&nbsp;&nbsp;</td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>

</div>
<!---->
<div align="center">

<table border="0" width="966" id="table3" cellspacing="0" cellpadding="5">
<tr>
<td align="center">
任务分类:<a  title="全部任务" href="Task.asp">全部任务</a> | 
 
<a  title="注册奖励" href="Task.asp?ClassID=1">注册奖励</a>
 | 
<a  title="游戏试玩" href="Task.asp?ClassID=2">游戏试玩</a>
 | 
<a  title="发贴转载" href="Task.asp?ClassID=3">发贴转载</a>
 | 
<a  title="下载体验" href="Task.asp?ClassID=4">下载体验</a>
 | 
<a  title="微博营销" href="Task.asp?ClassID=5">微博营销</a>
 | 
<a  title="其他奖励" href="Task.asp?ClassID=6">其他奖励</a>
 | <a title="收藏的任务" href="MyFavorites.asp" target="_blank"><span style="color:#ff6600;">我的收藏</span></a>
</td>
</tr><tr height=10 bgcolor="#FF0000"><td>
</table>

<!--推荐任务-->
<table border="0" width="966" id="table3" cellspacing="0" cellpadding="5">
                    <tr>
                      <td align="left"><%=AdsTask.RenWuTj()%>
                                                &nbsp;&nbsp;&nbsp;&nbsp;提示:<a href="vipbj.asp" target="_blank">VIP赚客奖励比普通赚客奖励多30%</a></td>
                      <td align="left"> <form name=f action=/tasktj.asp onSubmit="S.Common.stat('searchSubmit');" target="a">
                                                            <input name=id id=kw style="width:100px;" value="输入任务编号" maxlength=60 onClick="this.value=''">
                                                            <input name="submit" type=submit class=btn id=su onMouseDown="this.className='btn btn_h'" onMouseOut="this.className='btn'" value="查找">
                                                            </form>
                                          </td>
                    </tr>
<!--官方推荐开始-->
                    <tr>
                        <td colspan="2" align="center">
                            <table border="0" width="966" id="table5" cellspacing="1" cellpadding="5" bgcolor="#E7E7E7">
                            <tr>
                                <td align="center" width="40" class="b">
                                编  号</td>
                                <td align="center" width="350" class="b">
                                置顶推荐任务 <font color='ff0000'><a target='_blank' href="Notice.asp?id=772">(加入置顶任务,每次操作消耗<%=TuiJianJine%><%=adbname%>)</a></font></td>
                                <td align="center" width="60" class="b">
                                剩余名额</td>
                                <td align="center" width="52" class="b">
                                已完成</td>
                                <td align="center" width="53" class="b">
                                通过率</td>
                                <td align="center" width="60" class="b">
                                审核速度</td>
                                <td align="center" width="60" class="b">
                                普通奖励</td>
                                <td align="center" width="60" class="b">
                                VIP奖励</td>
                                <td align="center" width="80" class="b">
                                联系广告主</td>
                                <td align="center" width="35" class="b">
                                投诉</td>
                            </tr>
<!--金币推荐任务-->
<%
Set rsa=Server.CreateObject("ADODB.recordset")


select case ClassId
case 1
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case 2
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case 3
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case 4
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case 5
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case 6
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
case else
    mysq="select * from AdsTask_renwu where JinTuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by TuiJianTime desc"
end select


rsa.open mysq,conn,1,3
i=0
j=20    '显示数目
do while not rsa.eof and i<j

rnum=rsa("rnum")    '任务名额

'已通过的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=1"
rs_bfb.open mysq_bfb,conn,1,1
    tj1=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'被打回的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin not like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj2=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'等待审核的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj3=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing

if tj1<>0 then        '已通过的数量
    tj=formatnumber(tj1/(tj1+tj2)*100,2,-1)
else
    tj=0
end if
tp=int(tj/10)        '图片标识
if tj1=0 and tj2=0 then        '新任务,未被提交过
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&""" src=image/bfb/10.gif>"
else
'    tj=tj&"%"
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&" 通过率:"&tj&"%"" src=image/bfb/"&tp&".gif>"
end if

'更新竞价奖励参数
id=rsa("id")
addjine=rsa("addjine")
adusername=rsa("username")
if addjine>0 then
    call GetUser_State(adusername,1)
    if AdsTask.GetUserJine(adusername)<=(tj3+rnum)*addjine then
        conn.Execute("Update AdsTask_renwu Set addjine=0 where id="&id&"")
    end if
end if
%>
                            <tr>
                                <td bgcolor="#FFFFFF">
                                <a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=rsa("id")%></a></td>
                                <td bgcolor="#FFFFFF">
                                ·<a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=AdsTask.strvalue(rsa("title"),50)%></a></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("rnum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("oknum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=tj%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=GetSHtime(rsa("id"),1)%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per%></b></font> <%=adbname%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per_vip%></b></font> <%=adbname%></td>
<%
    Set rsb=Server.CreateObject("ADODB.recordset")
    mysq="select oicq from AdsTask_user where username='"&rsa("username")&"'"
    rsb.open mysq,conn,1,1
            if not rsb.bof and not rsb.eof then
        oicq=rsb("oicq")
            end if
    rsb.close
    set rsb=nothing
%>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=oicq%>&Site=<%=adurl%>&Menu=no><img border="0" SRC=http://wpa.qq.com/pa?p=1:<%=oicq%>:45 alt="点此处联系广告主审核任务 QQ:<%=oicq%>">审核任务</td>
                                <td bgcolor="#FFFFFF" align="center">
                                <a target='_blank' href="jubao.asp?t=举报该任务_ID:<%=rsa("id")%>">举报</a></td>
                            </tr>
<%
    i=i+1
rsa.movenext
loop
rsa.close
set rsa=nothing
%>
<!--金币推荐任务-->
                        </table>
                        </td>
                    </tr>

<!--金币推荐结束-->

<!--官方推荐开始-->
                    <tr>
                        <td colspan="2" align="center">
                            <table border="0" width="966" id="table5" cellspacing="1" cellpadding="5" bgcolor="#E7E7E7">
                            <tr>
                                <td align="center" width="40" class="b">
                                编  号</td>
                                <td align="center" width="350" class="b">
                                官方推荐 <font color='ff0000'><a target='_blank' href="faq.asp?id=22">(看官方推荐条件,加入推荐请点这里)</a></font></td>
                                <td align="center" width="60" class="b">
                                剩余名额</td>
                                <td align="center" width="52" class="b">
                                已完成</td>
                                <td align="center" width="53" class="b">
                                通过率</td>
                                <td align="center" width="60" class="b">
                                审核速度</td>
                                <td align="center" width="60" class="b">
                                普通奖励</td>
                                <td align="center" width="60" class="b">
                                VIP奖励</td>
                                <td align="center" width="80" class="b">
                                联系广告主</td>
                                <td align="center" width="35" class="b">
                                投诉</td>
                            </tr>
<!--推荐任务-->
<%
Set rsa=Server.CreateObject("ADODB.recordset")


select case ClassId
case 1
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 2
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 3
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 4
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 5
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 6
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case else
    mysq="select * from AdsTask_renwu where TuiJian=1 and rnum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
end select


rsa.open mysq,conn,1,3
i=0
j=20    '显示数目
do while not rsa.eof and i<j

rnum=rsa("rnum")    '任务名额

'已通过的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=1"
rs_bfb.open mysq_bfb,conn,1,1
    tj1=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'被打回的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin not like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj2=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'等待审核的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj3=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing

if tj1<>0 then        '已通过的数量
    tj=formatnumber(tj1/(tj1+tj2)*100,2,-1)
else
    tj=0
end if
tp=int(tj/10)        '图片标识
if tj1=0 and tj2=0 then        '新任务,未被提交过
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&""" src=image/bfb/10.gif>"
else
'    tj=tj&"%"
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&" 通过率:"&tj&"%"" src=image/bfb/"&tp&".gif>"
end if

'更新竞价奖励参数
id=rsa("id")
addjine=rsa("addjine")
adusername=rsa("username")
if addjine>0 then
    call GetUser_State(adusername,1)
    if AdsTask.GetUserJine(adusername)<=(tj3+rnum)*addjine then
        conn.Execute("Update AdsTask_renwu Set addjine=0 where id="&id&"")
    end if
end if
%>
                            <tr>
                                <td bgcolor="#FFFFFF">
                                <a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=rsa("id")%></a></td>
                                <td bgcolor="#FFFFFF">
                                ·<a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=AdsTask.strvalue(rsa("title"),50)%></a></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("rnum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("oknum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=tj%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=GetSHtime(rsa("id"),1)%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per%></b></font> <%=adbname%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per_vip%></b></font> <%=adbname%></td>
<%
    Set rsb=Server.CreateObject("ADODB.recordset")
    mysq="select oicq from AdsTask_user where username='"&rsa("username")&"'"
    rsb.open mysq,conn,1,1
            if not rsb.bof and not rsb.eof then
        oicq=rsb("oicq")
            end if
    rsb.close
    set rsb=nothing
%>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=oicq%>&Site=<%=adurl%>&Menu=no><img border="0" SRC=http://wpa.qq.com/pa?p=1:<%=oicq%>:45 alt="点此处联系广告主审核任务 QQ:<%=oicq%>">审核任务</td>
                                <td bgcolor="#FFFFFF" align="center">
                                <a target='_blank' href="jubao.asp?t=举报该任务_ID:<%=rsa("id")%>">举报</a></td>
                            </tr>
<%
    i=i+1
rsa.movenext
loop
rsa.close
set rsa=nothing
%>
<!--推荐任务-->
                        </table>
                        </td>
                    </tr>

<!--官方推荐结束-->
                    <tr>
                        <td colspan="2" align="center">
                            <table border="0" width="966" id="table5" cellspacing="1" cellpadding="5" bgcolor="#E7E7E7">
                            <tr>
                                <td align="center" width="40" class="b">
                                编  号</td>
                                <td align="center" width="350" class="b">
                                系统自动推荐 <font color='#60a1e3'>至少1人通过 通过率100% 1小时内审核</font></td>
                                <td align="center" width="60" class="b">
                                剩余名额</td>
                                <td align="center" width="52" class="b">
                                已完成</td>
                                <td align="center" width="53" class="b">
                                通过率</td>
                                <td align="center" width="60" class="b">
                                审核速度</td>
                                <td align="center" width="60" class="b">
                                普通奖励</td>
                                <td align="center" width="60" class="b">
                                VIP奖励</td>
                                <td align="center" width="80" class="b">
                                联系广告主</td>
                                <td align="center" width="30" class="b">
                                投诉</td>
                            </tr>
<%
Set rsa=Server.CreateObject("ADODB.recordset")

select case ClassId
case 1
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 2
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 3
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 4
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 5
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case 6
    mysq="select * from AdsTask_renwu where ClassId="&ClassId&" and rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
case else
    mysq="select * from AdsTask_renwu where rnum>0 and oknum>0 and lock=0 and Adlock=0 and jubaonum<"&JuBaoNum&" order by (jine+addjine) desc"
end select

rsa.open mysq,conn,1,3
i=0
j=30    '显示数目
do while not rsa.eof and i<j

rnum=rsa("rnum")    '任务名额

'已通过的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=1"
rs_bfb.open mysq_bfb,conn,1,1
    tj1=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'被打回的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin not like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj2=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'等待审核的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rsa("id")&" and yesno=0 and yuanyin like ''"
rs_bfb.open mysq_bfb,conn,1,1
    tj3=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing

if tj1<>0 then        '已通过的数量
    tj=formatnumber(tj1/(tj1+tj2)*100,2,-1)
else
    tj=0
end if
tp=int(tj/10)        '图片标识
if tj1=0 and tj2=0 then        '新任务,未被提交过
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&""" src=image/bfb/10.gif>"
else
'    tj=tj&"%"
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&" 通过率:"&tj&"%"" src=image/bfb/"&tp&".gif>"
end if

'已经通过数>0 被打回数量=0 
if tj1>0 and tj2=0 and GetSHtime(rsa("id"),0)>6 then

'更新竞价奖励参数
id=rsa("id")
addjine=rsa("addjine")
adusername=rsa("username")
if addjine>0 then
    call GetUser_State(adusername,1)
    if AdsTask.GetUserJine(adusername)<=(tj3+rnum)*addjine then
        conn.Execute("Update AdsTask_renwu Set addjine=0 where id="&id&"")
    end if
end if
%>
                            <tr>
                                <td bgcolor="#FFFFFF">
                                <a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=rsa("id")%></a></td>
                                <td bgcolor="#FFFFFF">
                                ·<a target="_blank" href="tasktj.asp?id=<%=rsa("id")%>"><%=AdsTask.strvalue(rsa("title"),50)%></a></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("rnum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rsa("oknum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=tj%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=GetSHtime(rsa("id"),1)%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per%></b></font> <%=adbname%></td>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><%=(rsa("jine")+rsa("addjine"))*Per_vip%></b></font> <%=adbname%></td>
<%
    Set rsb=Server.CreateObject("ADODB.recordset")
    mysq="select oicq from AdsTask_user where username='"&rsa("username")&"'"
    rsb.open mysq,conn,1,1
            if not rsb.bof and not rsb.eof then
        oicq=rsb("oicq")
            end if
    rsb.close
    set rsb=nothing
%>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=oicq%>&Site=<%=adurl%>&Menu=no><img border="0" SRC=http://wpa.qq.com/pa?p=1:<%=oicq%>:45 alt="点此处联系广告主审核任务 QQ:<%=oicq%>">审核任务</td>
                                <td bgcolor="#FFFFFF" align="center">
                                <a target='_blank' href="jubao.asp?t=举报该任务_ID:<%=rsa("id")%>">举报</a></td>
                            </tr>
<%
    i=i+1
end if
rsa.movenext
loop
rsa.close
set rsa=nothing
%>

                        </table>
 </td>
        </tr>
    </table>
<!--普通任务-->
                <table border="0" width="800" id="table3" cellspacing="0" cellpadding="5">
                    <tr>
                        <td align="left">请选择排列方式:
                        <%if p="renwutime" then%>▽【按发布时间排列】<%else%><a href='?p=0'>【按发布时间排列】</a><%end if%>&nbsp;&nbsp;
                        <%if p="rnum" then%>▽【按剩余名额排列】</a> <%else%><a href='?p=1'>【按剩余名额排列】</a><%end if%>&nbsp;&nbsp;
                        <%if p="jine" then%>▽【按奖励金币排列】 <%else%><a href='?p=2'>【按奖励金币排列】</a><%end if%>
                         </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <table border="0" width="966" id="table5" cellspacing="1" cellpadding="5" bgcolor="#E7E7E7">

                            <tr>
                                <td align="center" width="40" class="b">
                                编  号</td>
                                <td align="center" width="350" class="b">
                                所有任务标题</td>
                                <td align="center" width="60" class="b">
                                剩余名额</td>
                                <td align="center" width="52" class="b">
                                已完成</td>
                                <td align="center" width="53" class="b">
                                通过率</td>
                                <td align="center" width="60" class="b">
                                审核速度</td>
                                <td align="center" width="60" class="b">
                                普通奖励</td>
                                <td align="center" width="60" class="b">
                                VIP奖励</td>
                                <td align="center" width="80" class="b">
                                联系广告主</td>
                                <td align="center" width="35" class="b">
                                投诉</td>
                            </tr>
<%
for j=1 to rs.pagesize
if rs.eof then exit for

rnum=rs("rnum")    '任务名额

'已通过的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rs("id")&" and yesno=1"
rs_bfb.open mysq_bfb,conn,1,1
tj1=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'被打回的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rs("id")&" and yesno=0 and yuanyin not like ''"
rs_bfb.open mysq_bfb,conn,1,1
tj2=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing
'等待审核的数量
Set rs_bfb=Server.CreateObject("ADODB.recordset")
mysq_bfb="select * from AdsTask_renwu_tj where renwuid="&rs("id")&" and yesno=0 and yuanyin like ''"
rs_bfb.open mysq_bfb,conn,1,1
tj3=rs_bfb.recordcount
rs_bfb.close
set rs_bfb=nothing

if tj1<>0 then
    tj=formatnumber(tj1/(tj1+tj2)*100,2,-1)
else
    tj=0
end if
tp=int(tj/10)
if tj1=0 and tj2=0 then
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&""" src=image/bfb/10.gif>"
else
'    tj=tj&"%"
    tj="<img border=0 alt=""提交数/通过数:"&(tj1+tj2)&"/"&tj1&" 通过率:"&tj&"%"" src=image/bfb/"&tp&".gif>"
end if

'更新竞价奖励参数
id=rs("id")
addjine=rs("addjine")
adusername=rs("username")
if addjine>0 then
    call GetUser_State(adusername,1)
    if AdsTask.GetUserJine(adusername)<=(tj3+rnum)*addjine then
        conn.Execute("Update AdsTask_renwu Set addjine=0 where id="&id&"")
    end if
end if
%>
                            <tr>
                                <td bgcolor="#FFFFFF">
                                <a target="_blank" href="tasktj.asp?id=<%=rs("id")%>"><%=rs("id")%></a></td>
                                <td bgcolor="#FFFFFF">·<a target="_blank" href="tasktj.asp?id=<%=rs("id")%>"><%=AdsTask.strvalue(rs("title"),56)%></a></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rs("rnum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=rs("oknum")%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=tj%></td>
                                <td bgcolor="#FFFFFF" align="center"><%=GetSHtime(rs("id"),1)%></td>
                                <td bgcolor="#FFFFFF" align="center"><font color="#009933"><b><%=(rs("jine")+rs("addjine"))*Per%></b></font> <%=adbname%></td>
                                <td bgcolor="#FFFFFF" align="center"><font color="#009933"><b><%=(rs("jine")+rs("addjine"))*Per_vip%></b></font> <%=adbname%></td>
<%
    Set rsb=Server.CreateObject("ADODB.recordset")
    mysq="select oicq from AdsTask_user where username='"&rs("username")&"'"
    rsb.open mysq,conn,1,1
            if not rsb.bof and not rsb.eof then
        oicq=rsb("oicq")
            end if
    rsb.close
    set rsb=nothing
%>
                                <td bgcolor="#FFFFFF" align="center">
                                <font color="#009933"><b><a target=blank href=http://wpa.qq.com/msgrd?V=1&Uin=<%=oicq%>&Site=<%=adurl%>&Menu=no><img border="0" SRC=http://wpa.qq.com/pa?p=1:<%=oicq%>:45 alt="点此处联系广告主审核任务 QQ:<%=oicq%>">审核任务</td>
                                <td bgcolor="#FFFFFF" align="center"><a target='_blank' href="jubao.asp?t=举报该任务_ID:<%=rs("id")%>">举报</a></td>
                            </tr>
<%
rs.movenext
if rs.eof then exit for
next
%>
                            <tr>
                                <td colspan="10" align="center" class="c">任务总数:<%=rs.recordcount%>&nbsp;<%=AdsTask.page(pagenum,rs.pagecount)%></td>
                            </tr>
                        </table>
 </td>
        </tr>
    </table>
</div>
<!--#include file="bottom.asp"-->
<!--#include file="Dll_Unload.asp"-->
</body>

</html>

<%
'获取等待的最长时间
Function GetSHtime(renwuid,flag)
    renwuid=int(renwuid)
    Set rs_t=Server.CreateObject("ADODB.recordset")
    mysq_t="select top 1 id,tijiaotime from AdsTask_renwu_tj where renwuid="&renwuid&" and yesno=0 and yuanyin like '' order by tijiaotime desc"
    rs_t.open mysq_t,conn,1,1
        if not (rs_t.bof or rs_t.eof) then
            tijiaotime=rs_t("tijiaotime")
        else
            tijiaotime=""
        end if
    rs_t.close
    set rs_t=nothing

    if tijiaotime<>"" then
        s=DateDiff("s",tijiaotime,now())
        d=int(s/60/60/24)
        h=int((s-d*24*60*60)/60/60)
        n=int((s-d*24*60*60-h*60*60)/60)
        s=int((s-d*24*60*60-h*60*60-n*60))

        str="审核参考时间最迟需要等待"
        if d>0 then str=str&d&""
        if h>0 then str=str&h&"小时"
        if n>0 then str=str&n&""
        if s>0 then str=str&s&""
        str=str&""

            if d>7 then        '大于7天
            img=0
        elseif d>3 then        '大于3天
            img=1
        elseif d>0 then        '大于1天
            img=2
        elseif d=0 and h>12 then    '大于12小时
            img=3
        elseif d=0 and h>6 then        '大于6小时
            img=4
        elseif d=0 and h>3 then        '大于3小时
            img=5
        elseif d=0 and h>0 then    '大于1小时
            img=6
        elseif d=0 and h=0 and n>30 then    '大于30分钟
            img=7
        elseif d=0 and h=0 and n>10 then    '大于10分钟
            img=8
        else                '小于10分钟
            img=9
        end if
    else
        str="新任务或立即审核"
        img=10
    end if

    if flag=1 then
        GetSHtime=waittime&"<img border=0 alt="""&str&""" src=image\xingxing\xingxing_"&img&".gif>"
    else
        GetSHtime=img
    end if
    
End Function
%>
龙烟的主页 龙烟 | 初学一级 | 园豆:31
提问于:2013-01-14 00:18
< >
分享
最佳答案
0

但要完全读取及显示需要大概1分钟的时间。

你的测试应该是游览器发出请求到最后的完全呈现的总时间,对吧?

那这样的话,你可以把你的数据读取那块的时间单独的测试一下,看看消耗多久的时间。

可以用数据库的执行计划,看看,你的sql语句,开销在哪个点上

收获园豆:200
chenping2008 | 大侠五级 |园豆:9836 | 2013-01-14 09:04
其他回答(5)
0
2012 | 园豆:21230 (高人七级) | 2013-01-14 08:45
0

有你这么写的么?你那个读取后的循环内部为什么还要继续打开数据库读取数据?为什么不在一次将所需要使用的数据全部读取出来呢?

Daniel Cai | 园豆:10424 (专家六级) | 2013-01-14 09:55
0

建议你先看一下数据库里面查询要多长时间,看一下在哪一块开销最大

狼图腾TOP | 园豆:322 (菜鸟二级) | 2013-01-15 18:32
0

select * from 这样的写法尽量避免,只取要用的字段。。。

但是只有1万条数据的话,也不应该慢成这样的,查一下开销是需要的。

Alex_QY1987 | 园豆:1888 (小虾三级) | 2013-01-18 17:39
0

楼主提问最好把重点代码贴出来,你这贴这么多,大部分人看见就走了,谁会仔细看呢,我说下我的看法,第一你做不做索引在你目前的数据情况下是没有关系的,总共才1W条数据而已,我认为最大的瓶颈是你没取一部分数据就链接一次DB,整个页面你链接了多少次DB,估计有10次了吧,就DB的连接都耗掉你一半时间了,建议你一次性把需要的数据取出来,而不是每次都取数据,如果你真实的数据量比较大,最好把SQL写的规范些,做做索引。数据比较小,比如就几W条,可以不写,不过SQL写规范了是一种习惯,也显的我们专业些,哈哈

老孟Flutter | 园豆:55 (初学一级) | 2013-01-21 11:50
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册