2
我编写了一条SQL语句,各个语句运行良好,但是当我使用UNION将它们组合在一起时,语句花费的时间显着延长。是否有我错过的错误或使其更快的方法?UNION导致SQL语句运行慢很多
select bundle.bundle, bundle.week, bundle.sched_dt, dropper_assign.dropper_id
from bundle, dropper_assign
where bundle.bundle not in
(select bundle from forecast_entry)
and bundle.week = dropper_assign.week
and bundle.sched_zip3 = dropper_assign.zip3
and bundle.sched_dt = dropper_assign.sched_date
and bundle.project_cd = dropper_assign.project_code
and dropper_assign.dropper_id <> 10002
and bundle.project_cd = 'EXFC'
union
select bundle.bundle, bundle.week, bundle.sched_dt, splits.dropper_id
from bundle, splits
where bundle.bundle not in
(select bundle from forecast_entry)
and bundle.bundle = splits.bundle
and splits.dropper_id <> 10002
and bundle.project_cd = 'EXFC';
如果您确定没有重复项,请改用'UNION ALL' – van