我有一个插入的存储过程,(合并)需要几个小时才能运行。我注意到,当我拆分存储过程时(1)小时,日,星期,2)月,年);这两个存储过程的运行速度远快于一个大型存储过程的运行速度。在第一个存储过程结束后运行第二个存储过程的最佳解决方案是什么?我一直在网上寻找无济于事的解决方案。我也不认为触发器会起作用,因为这些“内部案例”存储过程中的每一个都旨在处理数百个插入。下面是我的代码(淡化):预先感谢!
也:如果我可以对代码进行其他改进,则可以感谢所有反馈:)
原始代码:
create or replace PROCEDURE STORED_PROCEDURE_COMBINED
is
CURSOR hour IS
SELECT distinct HOUR as HOUR
FROM TABLE
WHERE FLAG = 0;
CURSOR day is
SELECT distinct day as day
FROM TABLE
WHERE FLAG = 0;
l_hr hour%ROWTYPE;
l_day days%ROWTYPE;
INSERT_HOUR(l_hr.hour);
INSERT_DAY(l_day.day);
INSERT_WEEK(l_day.day);
INSERT_MONTH(l_day.day);
INSERT_YEAR(l_day.day);
END STORED_PROCEDURE_COMBINED;
我想要的:
create or replace PROCEDURE STORED_PROCEDURE_1
is
CURSOR hour IS
SELECT distinct HOUR as HOUR
FROM TABLE
WHERE FLAG = 0;
CURSOR day is
SELECT distinct day as day
FROM TABLE
WHERE FLAG = 0;
l_hr hour%ROWTYPE;
l_day days%ROWTYPE;
INSERT_HOUR(l_hr.hour);
INSERT_DAY(l_day.day);
INSERT_WEEK(l_day.day);
END STORED_PROCEDURE_1;
以上过程在完成后将启动以下过程:
create or replace PROCEDURE STORED_PROCEDURE_2
is
CURSOR day is
SELECT distinct day as day
FROM TABLE
WHERE FLAG = 0;
l_day days%ROWTYPE;
INSERT_MONTH(l_day.day);
INSERT_YEAR(l_day.day);
END STORED_PROCEDURE_2;
答案 0 :(得分:1)
getFeature
根据需要添加提交,错误检查和异常处理。