ADO的BUG,一个时间控件内操作一个数据库越来越慢! (100分)

  • 主题发起人 delphiplayer
  • 开始时间
D

delphiplayer

Unregistered / Unconfirmed
GUEST, unregistred user!
我在一个时间控件里写着对一个表内近80记录,每5秒进行编辑和POST发现程序运行起来
开始的时候很快但是后来越来越慢不知道到是什么原因(我用的是ado+accsess)。
 
慢成怎样,说详细点?
 
就是要再次对表操作的时候需要等待一段很长的时间,但开始的时候很快
几乎感觉不到。包括其它操作也相应被影响!估计是ADO的BUG?
 
发现同样情况!关注!
 
thinknet你是否有在每次执行的时候打开和关闭数据库,我是有的但速度还是不见有效!
 
我是定时OPEN数据库或根据用户的动作UPDATE数据,在OPEN或EXECSQL前先关闭ADOQUERY,
客户端需要查看数据的,但发现速度越来越慢,有时甚至DOWN机。
 
状况一样!我是退出程序再进入时就恢复正常,但运行一段时间速度就越来越慢!有
人说这是ADO没有释放资源造成的!但平常我们操作数据库都没问题啊!问题是出现在
将数据库的保存和更新操作放在时间控件里估计跟线程有关????
 
我后来干脆让用户用一段时间就退出来再进去,就没事了!
我还一直以为是我的程序设计有问题,原来并非我一人如此!!!
不知能否解决!
 
在正规的开发这样是不允许的,我想用多线程的方法试一下!
 
检查你的服务器的优化方面
 
已在多台电脑上试过!一样的结果!
 
你们是不是用了 TTimer 控件,ontimer处理过程能在定时时间内完成吗?
 
是这样的我在TIMER的开始处写着TIME1.ENABLE:=FALSE在未尾处写time1.enable:=true
 
具体源码哪,我试了一下读数据没发现问题.还是我等的时间不够长?
 
当然只单独运行这一段它占用的内存很少所以发作地比较慢大约要一两小时
如果和其它模块共用大约30分钟就有效果了。
procedure Tbuy.Timer1Timer(Sender: TObject);
var
gzsz:array[1..60] of boolean;
jsrs,xsrs,hyrs,ykrs,txrs:integer;
i:integer;
begin
timer1.Enabled:=false;
jsrs:=0;
xsrs:=0;
hyrs:=0;
ykrs:=0;
txrs:=0;
i:=1;
with data.gzwl do
begin
close;
open;
first;
while not Eof do
begin
if fieldbyname('fs').value='apple' then
jsrs:=jsrs+1
else if fieldbyname('fs').Value='orange' then
hyrs:=hyrs+1
else if fieldbyname('fs').Value='banger' then
txrs:=txrs+1
else if fieldbyname('fs').Value='sandwich' then
xsrs:=xsrs+1
else if fieldbyname('fs').Value='egg' then
ykrs:=ykrs+1;
gzsz:=fieldbyname('netopen').Value;
next;
i:=i+1;
end;
close;
end;
if gzsz[1]=true then gz1.Color:=clLime
else gz1.Color:=clred;
if gzsz[2]=true then gz2.Color:=cllime
else gz2.Color:=clred;
if gzsz[3]=true then gz3.Color:=cllime
else gz3.Color:=clred;
if gzsz[4]=true then gz4.Color:=cllime
else gz4.Color:=clred;
if gzsz[5]=true then gz5.Color:=cllime
else gz5.Color:=clred;
if gzsz[6]=true then gz6.Color:=cllime
else gz6.Color:=clred;
if gzsz[7]=true then gz7.Color:=cllime
else gz7.Color:=clred;
if gzsz[8]=true then gz8.Color:=cllime
else gz8.Color:=clred;
if gzsz[9]=true then gz9.Color:=cllime
else gz9.Color:=clred;
if gzsz[10]=true then gz10.Color:=cllime
else gz10.Color:=clred;
if gzsz[11]=true then gz11.Color:=cllime
else gz11.Color:=clred;
if gzsz[12]=true then gz12.Color:=cllime
else gz12.Color:=clred;
if gzsz[13]=true then gz13.Color:=cllime
else gz13.Color:=clred;
if gzsz[14]=true then gz14.Color:=cllime
else gz14.Color:=clred;
if gzsz[15]=true then gz15.Color:=cllime
else gz15.Color:=clred;
if gzsz[16]=true then gz16.Color:=cllime
else gz16.Color:=clred;
if gzsz[17]=true then gz17.Color:=cllime
else gz17.Color:=clred;
if gzsz[18]=true then gz18.Color:=cllime
else gz18.Color:=clred;
if gzsz[19]=true then gz19.Color:=clLime
else gz19.Color:=clred;
if gzsz[20]=true then gz20.Color:=cllime
else gz20.Color:=clred;
if gzsz[21]=true then gz21.Color:=cllime
else gz21.Color:=clred;
if gzsz[22]=true then gz22.Color:=cllime
else gz22.Color:=clred;
if gzsz[23]=true then gz23.Color:=cllime
else gz23.Color:=clred;
if gzsz[24]=true then gz24.Color:=cllime
else gz24.Color:=clred;
if gzsz[25]=true then gz25.Color:=cllime
else gz25.Color:=clred;
if gzsz[26]=true then gz26.Color:=cllime
else gz26.Color:=clred;
if gzsz[27]=true then gz27.Color:=cllime
else gz27.Color:=clred;
if gzsz[28]=true then gz28.Color:=cllime
else gz28.Color:=clred;
if gzsz[29]=true then gz29.Color:=cllime
else gz29.Color:=clred;
if gzsz[30]=true then gz30.Color:=cllime
else gz30.Color:=clred;
if gzsz[31]=true then gz31.Color:=cllime
else gz31.Color:=clred;
if gzsz[32]=true then gz32.Color:=cllime
else gz32.Color:=clred;
if gzsz[33]=true then gz33.Color:=cllime
else gz33.Color:=clred;
if gzsz[34]=true then gz34.Color:=cllime
else gz34.Color:=clred;
if gzsz[35]=true then gz35.Color:=cllime
else gz35.Color:=clred;
if gzsz[36]=true then gz36.Color:=cllime
else gz36.Color:=clred;
if gzsz[37]=true then gz37.Color:=cllime
else gz37.Color:=clred;
if gzsz[38]=true then gz38.Color:=cllime
else gz38.Color:=clred;
if gzsz[39]=true then gz39.Color:=cllime
else gz39.Color:=clred;
if gzsz[40]=true then gz40.Color:=cllime
else gz40.Color:=clred;
if gzsz[41]=true then gz41.Color:=cllime
else gz41.Color:=clred;
if gzsz[42]=true then gz42.Color:=cllime
else gz42.Color:=clred;
if gzsz[43]=true then gz43.Color:=cllime
else gz43.Color:=clred;
if gzsz[44]=true then gz44.Color:=cllime
else gz44.Color:=clred;
if gzsz[45]=true then gz45.Color:=cllime
else gz45.Color:=clred;
if gzsz[46]=true then gz46.Color:=cllime
else gz46.Color:=clred;
if gzsz[47]=true then gz47.Color:=cllime
else gz47.Color:=clred;
if gzsz[48]=true then gz48.Color:=cllime
else gz48.Color:=clred;
if gzsz[49]=true then gz49.Color:=clLime
else gz49.Color:=clred;
if gzsz[50]=true then gz50.Color:=cllime
else gz50.Color:=clred;
if gzsz[51]=true then gz51.Color:=cllime
else gz51.Color:=clred;
if gzsz[52]=true then gz52.Color:=cllime
else gz52.Color:=clred;
if gzsz[53]=true then gz53.Color:=cllime
else gz53.Color:=clred;
if gzsz[54]=true then gz54.Color:=cllime
else gz54.Color:=clred;
if gzsz[55]=true then gz55.Color:=cllime
else gz55.Color:=clred;
if gzsz[56]=true then gz56.Color:=cllime
else gz56.Color:=clred;
if gzsz[57]=true then gz57.Color:=cllime
else gz57.Color:=clred;
if gzsz[58]=true then gz58.Color:=cllime
else gz58.Color:=clred;
if gzsz[59]=true then gz59.Color:=cllime
else gz59.Color:=clred;
if gzsz[60]=true then gz60.Color:=cllime
else gz60.Color:=clred;
jslab.Caption:=inttostr(jsrs);
hylab.Caption:=inttostr(hyrs);
txlab.Caption:=inttostr(txrs);
xslab.Caption:=inttostr(xsrs);
yklab.Caption:=inttostr(ykrs);
tjlab.Caption:=inttostr(jsrs+hyrs+txrs+xsrs+ykrs);
timer1.Enabled:=true;
end;
 
faint,你的 gz1-60是什么,不能用个控件数组吗.不过从代码看不出慢的毛病,
不知道你在data.gzwl写过Afterscroll之流的事件处理过程没有.
 
没有只是一般的数据库操作,用的是ADODATASET,gzsz[1-60]是数值型静态数组。
 
同志,我可算找到你了!
半年前我也遇到同样的问题,但比你更新数据库的速度还频繁。
速度要求:“慢速1记录/s,快速7~8记录/s”。
用单独线程做记录,5分钟后速度明显放缓!单步跟踪发现Post语句变得运行极慢!
最后我的解决方法是“定义结构化文件”,自己写添加、删除、查询语句。
速度方面绝对没问题,记录几十个小时都不会变慢。用文件吧,除了移植性差,编程量大
些,性能没的说。
 
将CLose,open取消调试试。
 
vecm您好非常感谢您提供的资料,但定义结构文件!天啊!我不是要累死!有没有其它办法
,还有我听有人说这是因为ACCESS要记录日志文件造成的?我们是不是能找到更容易点办
法,比如不要用ACCESS用ODBC的其它表可以吗请指教!
 
顶部