函数要减少运算时间,要尽量避免重复计算以及重复调用函数。这个在Select语句里面尤其要引起注意。
data := rand(100,10)-0.5;
select * from data where [getcol()]>0.3 end;
getcol函数如下:
function getcol()
begin
return 0;
end
在Selct语句的where语句中,我们重复调用了很多次getcol。这里我们建议先计算getcol再使用Select语句。
temp := getcol();
select * from data where [temp]>0.3 end;
另外,在Select语句中,表之间做连接的On条件没有做优化,如果要进行优化加速,建议采用With On条件。