- 论坛徽章:
- 0
|
OneZ说得没错,对表建立索引,查询性能会有相当大的提高。
另外,在做应用时,比较复杂的SQL查询语句在运行成功后,可以拆成多个简单语句并放入一个函数来实现,这样会显著提高查询的性能。我的课题中曾有一个不算复杂的四表关系查询,测试平均耗时为51ms,而将它拆成三条简单查询语句并写成函数过程,测试的平均耗时立刻降为20ms。相关章节的例子如下:
修改前:
select d023.code
from d023, d023a, d023d, z001
where d023.attr=d023a.code
and d023d.code=d023a.code
and d023d.z001=z001.ser
and d023.name=funame
and z001.pcode=fjcode
and d023d.allow='T'
修改后:
rcode:=(select attr from d023 where name=funame);
scode:=(select ser from z001 where pcode=fjcode);
if (select allow from d023d
where code=rcode and z001=scode) = ''T''
then
return ''AuthSaysIdentAllowed'';
end if;
return ''AuthSaysIdentDisable'';
是不是很简单? |
|