【发布时间】:2019-11-09 15:17:45
【问题描述】:
我的一个过程调用调用函数并将返回值绑定到变量。请看下面:
此查询正在过程中执行。
旧查询
--lc_tmp_year is variable declare at procedure level
--this call taking 3 secs to execute
lc_tmp_year = EmpPackage.GetEmployeeCodeYear(emp_id);
select * from employeePlans
where code_year = lc_tmp_year;
新查询
--this running faster than the above one - within secs
select * from employeePlans
where code_year = EmpPackage.GetEmployeeCodeYear(emp_id);;
我很惊讶为什么新查询比旧查询运行得更快。
有人知道吗?
【问题讨论】:
-
请提供有关表大小和执行计划的信息。
标签: sql oracle11g query-optimization