小编use*_*565的帖子

ORACLE PL/SQL包需要几个小时才能完成

我有一个Oracle包,其输入参数为开始日期sysdate-365,结束日期为sysdate + 90.它找到从sysdate-365到sysdate + 90的每个日期,这是455天,然后它为每个日期循环,从主表中获取记录再次循环基于主表数据,从其他表获取值,做一些逻辑并插入工作台.完成需要10个多小时.

我想过使用dbms_scheduler来运行包并行,因为DBA不建议这样做.任何人都可以建议任何其他方式来提高性能?

代码段:

loop for date range
select some_data from master_table where master_date = cursor.date;


loop for 
select other_data from other_table where other_date = cursor.date
start with some_data 
connect by other_parent = prior other_child;


select count(*) into v1cnt from third_table where third_date = cursor.date and third_data=other_data; 

if v1cnt  > 0 then
select third_data into variable1 from third_table where third_date = cursor.date and third_data=other_data; 
else
variable1 = null;
end if;

select count(*) into v2cnt from fourth_table where …
Run Code Online (Sandbox Code Playgroud)

sql oracle plsql

-1
推荐指数
1
解决办法
186
查看次数

标签 统计

oracle ×1

plsql ×1

sql ×1