我有我的項目中執行以下查詢:使用子查詢時,Oracle查詢運行速度非常慢。這能糾正嗎?
SELECT fcr.request_id,
DECODE
(fcpt.user_concurrent_program_name,
'Report Set', fcr.description,
'Request Set Stage', fcr.description,
fcpt.user_concurrent_program_name
) user_concurrent_program_name,
fcr.description, fcr.argument_text, fcr.concurrent_program_id,
fcr.parent_request_id, fcr.actual_start_date,
fcr.actual_completion_date,
ROUND ( (fcr.actual_completion_date - fcr.actual_start_date)
* 24
* 60,
4
) runtime,
DECODE (fcr.phase_code, 'C', 'No Schedule') program_status,
fu.user_name, frt.responsibility_name, fcr.logfile_name
FROM [email protected]_link fcr,
[email protected]_link fcpt,
[email protected]_link fu,
[email protected]_link frt
WHERE fcr.concurrent_program_id = fcpt.concurrent_program_id
AND fcr.requested_by = fu.user_id
AND fcr.responsibility_id = frt.responsibility_id
AND fcr.responsibility_application_id = frt.application_id
AND fcr.actual_completion_date >= (SELECT MAX (alert_logged_time)
FROM allen.main_table
WHERE program_status = 'No Schedule')
AND fcr.phase_code = 'C';
但上面的查詢時間過長運行。當我給相應的時間作爲輸入,而不是
SELECT MAX (alert_logged_time)
FROM allen.main_table
WHERE program_status = 'No Schedule'
我甚至很快得到輸出。爲什麼?無論如何要糾正這一點?
嘗試在列'(PROGRAM_STATUS,ALERT_LOGGED_TIME)'上向'ALLEN.MAIN_TABLE'添加一個索引。分享並享受。 –