我正在使用CTE在oracle中运行查询。 当我执行查询时,它在select语句中正常工作,但是当我使用insert语句时,需要大量的时间来执行。这里的任何帮助都是代码
INSERT INTO port_weeklydailypricesTest (co_code,start_dtm,end_dtm)
SELECT * FROM
(
WITH CTE(co_code, start_dtm, end_dtm) AS
(
SELECT co_code ,
CAST(NEXT_DAY(MIN(dlyprice_date),'FRIDAY')-6 AS DATE) start_dtm ,
CAST(NEXT_DAY(MIN(dlyprice_date),'FRIDAY') AS DATE) end_dtm
FROM feed_dlyprice
GROUP BY co_code
UNION ALL
SELECT co_code ,
CAST(TO_CHAR(end_dtm + INTERVAL '1' DAY,'DD-MON-YYYY') AS DATE),
CAST(TO_CHAR(end_dtm + INTERVAL '7' DAY,'DD-MON-YYYY') AS DATE)
FROM CTE
WHERE CAST(end_dtm AS DATE) <= TO_CHAR(TO_DATE(SYSDATE+1,'DD-MON-YYYY'))
)
SELECT co_code,start_dtm,end_dtm
FROM CTE
);
答案 0 :(得分:2)
正如你所说,如果SELECT本身的表现令人满意,那么问题必须出在声明的INSERT部分。
有许多事情可能会导致插件运行缓慢:
这绝不是详尽无遗的。顶部的项目是您应该能够调查和解决的应用程序问题。列表越靠后,您就越有可能需要现场DBA的帮助。