如何提高程序运行速度
我总习惯用FOR-ENDFOR编写统计代码,在几十个字段、不到1000行的代码中,对1000左右记录统计要运行20-30分钟,对3万条记录统计要运行几个小时(至少3个小时)。不知有何好的建议改进,谢谢![此贴子已经被作者于2020-9-12 21:17编辑过]
[此贴子已经被作者于2020-9-13 18:55编辑过]
CLOSE TABLES all USE b1 IN 0 ALIAS t1 BLANK FIELDS _1d, _1x,_1t,_2d, _2x,_2t ALL USE b1 IN 0 ALIAS t2 AGAIN SELECT t1 SET RELATION TO RECNO()+1 INTO "t2" REPLACE ALL t2._1d WITH IIF(t2.a1>t1.a1 ,"_1D", ""); t2._1x WITH IIF(t2.a1<t1.a1 ,"_1X", ""); t2._1t WITH IIF(t2.a1=t1.a1 ,"_1t", ""); t2._2d WITH IIF(t2.a2>t1.a2 ,"_2D", ""); t2._2x WITH IIF(t2.a2<t1.a2 ,"_2X", ""); t2._2t WITH IIF(t2.a2=t1.a2 ,"_2t", "") SET RELATION TO SELECT * FROM t1 BROWSE
CLOSE TABLES all USE b1 IN 0 ALIAS t1 BLANK FIELDS _1d, _1x,_1t,_2d, _2x,_2t ALL USE b1 IN 0 ALIAS t2 AGAIN SELECT t1 SET RELATION TO RECNO()+1 INTO "t2" p1=ALLTRIM("t1.")+ALLTRIM('a')+ALLTRIM('1') p11=&p1 k1=ALLTRIM("t2.")+ALLTRIM('a')+ALLTRIM('1') k11=&k1 p2=ALLTRIM("t1.")+ALLTRIM('a')+ALLTRIM('2') p22=&p2 k2=ALLTRIM("t2.")+ALLTRIM('a')+ALLTRIM('2') k22=&k2 REPLACE ALL t2._1d WITH IIF(k11>p11 ,"_1D", ""); t2._1x WITH IIF(k11<p11 ,"_1X", ""); t2._1t WITH IIF(k11=p11 ,"_1t", ""); t2._2d WITH IIF(k22>p22 ,"_2D", ""); t2._2x WITH IIF(k22<p22 ,"_2X", ""); t2._2t WITH IIF(k22=p22 ,"_2t", "") SET RELATION TO SELECT * FROM t1 BROWSE
[此贴子已经被作者于2020-9-13 18:45编辑过]