首页 > 解决方案 > 过程中的相同查询需要不同的时间

问题描述

我在程序中有相同的代码,只有 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)

标签: oraclevariablesplsqlprocedureexecution-time

解决方案


推荐阅读