如何提高程序运行速度
我总习惯用FOR-ENDFOR编写统计代码,在几十个字段、不到1000行的代码中,对1000左右记录统计要运行20-30分钟,对3万条记录统计要运行几个小时(至少3个小时)。不知有何好的建议改进,谢谢!
如果可能的话,多用数组。在内存中处理不耗用I/O,应该会快很多。
由于没有看到你的数据和意图,只能这么给你建议。
[此贴子已经被作者于2020-9-12 21:17编辑过]
USE b2 IN 0 ALIAS t1 USE b2 IN 0 ALIAS t2 AGAIN SELECT t1 SET RELATION TO RECNO()+1 INTO "t2" REPLACE ALL t2._1dxx WITH IIF("_"$t1._1d AND "_"$t2._1d OR "_"$t1._1x AND "_"$t2._1x OR "_"$t1._1t AND "_"$t2._1t, "_1DXX", ""); t2._1dxxf WITH IIF(EMPTY(t2._1dxx), "_1DXXF", "") SELECT * FROM t1
**转换结构格式 SELECT jnh, .F. _1dxx, ICASE(!EMPTY(_1d),1,!EMPTY(_1x),2,!EMPTY(_1t),3,0) _1dxt; FROM b2 INTO CURSOR t1 READWRITE SELECT _1dxt FROM t1 INTO CURSOR t2 SELECT t2 SET RELATION TO RECNO()+1 INTO "t1" REPLACE ALL t1._1dxx WITH t2._1dxt>0 AND t1._1dxt==t2._1dxt SELECT jnh,; IIF(_1dxx,"_1DXX",IIF(_1dxt>0,"_1DXXF"," ")) _1dxx,; ICASE(_1dxt==1,"_1D",_1dxt==2,"_1X",_1dxt==3,"_1T"," ") _1dxt FROM t1 ** 原结构格式显示 SELECT jnh,; IIF(!_1dxx AND _1dxt>0,"_1DXXF"," ") _1dxxf,; IIF(_1dxx,"_1DXX"," ") _1dxx,; IIF(_1dxt==1,"_1D"," ") _1d,; IIF(_1dxt==2,"_1X"," ") _1x,; IIF(_1dxt==3,"_1T"," ") _1t FROM t1 RETURN
[此贴子已经被作者于2020-9-13 09:43编辑过]