您能帮我优化以下 Union All Query 吗?知道从哪里开始吗?详细信息:SQL 计划显示
| 7 | 表访问完全 | DELAY_DATE | 17533 | 171K| 25 (0)| 00:00:01 |
| 8 | 表访问完全 | 空缺 | 25879 | 454K| 298 (1)| 00:00:04 |
| 16 | 合并加入笛卡尔| | 17533 | 273K| 28 (4)| 00:00:01 |
这些是潜在的问题吗?
SELECT delay_reason_desc, delay_start_date, delay_end_date, delay_reason_code
FROM delay_date dd
LEFT JOIN delay_reason dr
ON dr.delay_reason_id=dd.delay_reason_id
LEFT JOIN delay_interval di
ON di.delay_interval_id=dr.delay_interval_id
LEFT JOIN vacancy v
ON v.vacancy_id=dd.vacancy_id
WHERE dr.delay_reason_active_ind='Y'
--AND dd.vacancy_id=p_vacancy_id
AND delay_start_date >= vacancy_fpps_received_date
AND delay_end_date <= vacancy_open_date
AND delay_interval_code=1
UNION ALL
SELECT delay_reason_desc, delay_start_date, delay_end_date, delay_reason_code
FROM delay_date dd
LEFT JOIN delay_reason dr
ON dr.delay_reason_id=dd.delay_reason_id
LEFT JOIN delay_interval di
ON di.delay_interval_id=dr.delay_interval_id
LEFT JOIN vacancy v
ON v.vacancy_id=dd.vacancy_id
WHERE dr.delay_reason_active_ind='Y'
--AND dd.vacancy_id=p_vacancy_id
AND delay_start_date >= vacancy_open_date
AND delay_end_date <= vacancy_closed_date
AND delay_interval_code=2