Any tips on how to make this query run faster? This is the part that really slows it down:
"o.pr_dept_ou_id in
(
select c.pr_dept_ou_id
from s_org_ext oe, s_contact c
where oe.x_name = ' 1234' and c.last_name = '1234'
)"
select ord.order_num,
ordt.name,
orgint.name,
prodint.name,
oi.row_id,
oi.alw_part_ship_flg,
oi.billable_flg,
oi.ln_num,
oi.loaner_flg,
oi.rollup_flg,
oi.wrnty_rcvr_flg,
oi.discnt_src_cd,
oi.excl_pricing_flg,
oi.hold_flg,
oi.promo_item_flg,
oi.auto_recv_flg,
oi.processed_flg,
oi.ship_complete_flg,
oi.ship_together_flg,
oi.single_src_flg,
ord.rev_num
from s_opty o,
s_order ord,
s_order_type ordt,
s_prod_int prodint,
s_bu orgint,
s_order_item oi
where o.pr_dept_ou_id in
(
select c.pr_dept_ou_id
from s_org_ext oe, s_contact c
where oe.x_name = ' 1234' and c.last_name = '1234'
)
and o.row_id = ord.opty_id
and ord.row_id = oi.order_id
and ord.order_type_id = ordt.row_id
and oi.prod_id = prodint.row_id
and o.bu_id = orgint.row_id
and o.created < sysdate - 1
"o.pr_dept_ou_id in
(
select c.pr_dept_ou_id
from s_org_ext oe, s_contact c
where oe.x_name = ' 1234' and c.last_name = '1234'
)"
select ord.order_num,
ordt.name,
orgint.name,
prodint.name,
oi.row_id,
oi.alw_part_ship_flg,
oi.billable_flg,
oi.ln_num,
oi.loaner_flg,
oi.rollup_flg,
oi.wrnty_rcvr_flg,
oi.discnt_src_cd,
oi.excl_pricing_flg,
oi.hold_flg,
oi.promo_item_flg,
oi.auto_recv_flg,
oi.processed_flg,
oi.ship_complete_flg,
oi.ship_together_flg,
oi.single_src_flg,
ord.rev_num
from s_opty o,
s_order ord,
s_order_type ordt,
s_prod_int prodint,
s_bu orgint,
s_order_item oi
where o.pr_dept_ou_id in
(
select c.pr_dept_ou_id
from s_org_ext oe, s_contact c
where oe.x_name = ' 1234' and c.last_name = '1234'
)
and o.row_id = ord.opty_id
and ord.row_id = oi.order_id
and ord.order_type_id = ordt.row_id
and oi.prod_id = prodint.row_id
and o.bu_id = orgint.row_id
and o.created < sysdate - 1