oracle - 过程中的相同查询需要不同的时间
问题描述
我在程序中有相同的代码,只有 1 个不同(日期变量)。在我的代码中,我有 27 个 p_dt 变量。下面的代码不完整。当我用 p_dt 运行程序时,它花费了 10 多个小时,但是当我写 to_date('01.01.2020','dd.mm.yyyy') 而不是 p_dt 时,它花费了 300 秒
create or replace ru.t_maha(p_dt in date default trunc(sysdate) -1) as
begin
delete from t_maha_1
where dt = to_date(add_months(trunc(p_dt,'MONTH'),-1),'dd.mm.yyyy');
commit;
insert into t_maha_1
with scheta_Snt as (
select
inn,
add_months(trunc(p_dt,'MONTH'),-1) || last_Day(add_months(trunc(p_dt,'MONTH'),-1)) interval,
sum(case when t.dt_open between add_months(trunc(p_dt,'MONTH'),-1) and last_Day(add_months(trunc(p_dt,'MONTH'),-1)) then value_nat end ) scheta_snt
from fct_Carry t
)
select * from scheta_snt
join scheta_pop (same subquery but for another calculate)
join dep_snt (same subquery but for another calculate)
join dep_pop (same subquery but for another calculate)
解决方案
推荐阅读
- javascript - Vue - 如何访问计算属性的调用控制
- node.js - SAML SSO 与 Node 和 Angular 2+
- unity3d - 如何在网格实例化中使用点光源和聚光灯?
- r - 如何避免 RStudio 将临时文件写入 SSD?
- html - 为什么这些跨度的高度呈现不同?
- php - Wordpress Understrap 在页面上显示帖子
- git - 也应该在 PATH 中的脚本的版本控制
- angular - 用于状态管理的 Angular 和 rxjs subect
- android - 如何从firestore中的对象_field获取数据
- javascript - Modernizr.addTest() 不是函数