有没有办法使用Toad来检查或估计查询的进度?我有一个查询,它最好运行大约20分钟。因为我正在调整查询以尝试使其更快,有时它会在一个完整的循环中结束并且永远不会完成。有时可能需要一个小时。真正有用的是指示查询实际覆盖了多少基础,至少让我知道什么是更快或者什么使它变得更慢。
非常感谢任何帮助。
我已经包含了我的查询,只是有人可能会看到一些明显可能会提高效率的内容......
select * from
(select menu_optn_name, tran_nbr, seq_nbr, cntr_nbr, ch.total_qty, ptt.create_date_time,
um.user_name, ch.trlr_nbr, sum(ref_field_2) as Total from prod_trkg_tran ptt
inner join user_master um
on um.emplye_id = ptt.user_id
left outer join carton_hdr ch
on ch.carton_nbr = ptt.cntr_nbr
where (menu_optn_name = 'RF Split/Comb {Carton}' and ptt.cntr_nbr = '0030651942')
group by menu_optn_name, tran_nbr, seq_nbr, cntr_nbr, ch.total_qty, ptt.create_date_time,
um.user_name, ch.trlr_nbr
union
select aptt.menu_optn_name, aptt.tran_nbr, aptt.seq_nbr, aptt.cntr_nbr, ach.total_qty,
aptt.create_date_time, um.user_name, ach.trlr_nbr, sum(aptt.ref_field_2)
as Total from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
inner join user_master um
on um.emplye_id = aptt.user_id
left outer join wm_archive.carton_hdr@awm.corp.*******.com ach
on ach.carton_nbr = aptt.cntr_nbr
where aptt.cntr_nbr not in
(select aptt.cntr_nbr from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
where aptt.menu_optn_name = 'RF Split/Comb {Carton}' and aptt.cntr_nbr = '0030651942')
and aptt.tran_nbr in
(select aptt.tran_nbr from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
where aptt.menu_optn_name = 'RF Split/Comb {Carton}' and aptt.cntr_nbr = '0030651942')
group by aptt.menu_optn_name, aptt.tran_nbr, aptt.seq_nbr, aptt.cntr_nbr, ach.total_qty,
aptt.create_date_time, um.user_name, ach.trlr_nbr)
where rownum <=2;
7的
答案 0 :(得分:2)
我想说使用Explain Plan
选项( Ctrl + E )。它会根据您的查询的影响向您提供一个想法。
除此之外,确定查询的持续时间非常困难。
答案 1 :(得分:1)
您想要查看v $ session_longops表,例如http://docs.oracle.com/cd/B19306_01/server.102/b14237/dynviews_2092.htm
或者,如果您拥有具有调优和诊断功能的企业管理器,它将显示长时间运行的查询。否则将查询拆分为许多小部分并单独运行。找出需要很长时间并重写或索引的内容。也许把你的问题放在这里,我们可能会提出一些建议。如上所述,解释计划可能有所帮助。
我强烈建议您将查询格式化为可读性,例如
select * from
(select menu_optn_name,
tran_nbr,
seq_nbr,
cntr_nbr,
ch.total_qty,
ptt.create_date_time,
um.user_name,
ch.trlr_nbr,
sum(ref_field_2) as Total
from prod_trkg_tran ptt
inner join user_master um on um.emplye_id = ptt.user_id
left outer join carton_hdr ch on ch.carton_nbr = ptt.cntr_nbr
where (menu_optn_name = 'RF Split/Comb {Carton}'
and ptt.cntr_nbr = '0030651942')
group by menu_optn_name,
tran_nbr,
seq_nbr,
cntr_nbr,
ch.total_qty,
ptt.create_date_time,
um.user_name,
ch.trlr_nbr
union
select aptt.menu_optn_name,
aptt.tran_nbr,
aptt.seq_nbr,
aptt.cntr_nbr,
ach.total_qty,
aptt.create_date_time,
um.user_name,
ach.trlr_nbr,
sum(aptt.ref_field_2) as Total
from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
inner join user_master um on um.emplye_id = aptt.user_id
left outer join wm_archive.carton_hdr@awm.corp.*******.com ach on ach.carton_nbr = aptt.cntr_nbr
where aptt.cntr_nbr not in (select aptt.cntr_nbr
from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
where aptt.menu_optn_name = 'RF Split/Comb {Carton}'
and aptt.cntr_nbr = '0030651942')
and aptt.tran_nbr in (select aptt.tran_nbr
from wm_archive.prod_trkg_tran@awm.corp.*******.com aptt
where aptt.menu_optn_name = 'RF Split/Comb {Carton}'
and aptt.cntr_nbr = '0030651942')
group by aptt.menu_optn_name,
aptt.tran_nbr,
aptt.seq_nbr,
aptt.cntr_nbr,
ach.total_qty,
aptt.create_date_time,
um.user_name,
ach.trlr_nbr)
where rownum <=2;
你是否尝试过分别运行2个子选项,看看他们花了多长时间以及联盟的每一半。你真的只想要第一行(你可以尝试添加第一行提示 - SELECT / * + FIRST_ROWS * /)吗?你只能通过找到缓慢运行的特定部分来调整东西!