查詢:如何在計劃中使用'merge join cartesian'優化oracle查詢?
select max(b.counter) as counter,
b.m_group,
b.m_code,
a.s_id,
s.id_sk
from tbl_various a, tbl_map b, tbl_sheet s
where coalesce(b.part, a.part) = a.part
and coalesce(b.nums, to_number(a.nums)) = a.nums
and coalesce(b.interc, a.interc) = a.interc
and coalesce(b.segment, a.segment) = a.segment
and coalesce(b.acountry, a.acountry) = a.acountry_midas
and coalesce(b.orig_name, a.orig_name) = a.orig_name
and coalesce(b.fact, a.fact) = a.fact
and b.sect is not null
and s.m_code = b.m_code
group by b.m_group, b.m_code, a.s_id, s.id_sk;
計劃:
SELECT STATEMENT, GOAL = ALL_ROWS 86763 1 169
HASH GROUP BY 86763 1 169
HASH JOIN 86762 1 169
TABLE ACCESS FULL TBL_MAP 2 1717 92718
MERGE JOIN CARTESIAN 79688 300133251 34515323865
TABLE ACCESS FULL TBL_SHEET 5 912 18240
BUFFER SORT 79682 329274 31281030
TABLE ACCESS FULL TBL_VARIOUS 87 329274 31281030
集團通過太慢......它是如何加快?
您是否嘗試過表'tbl_map'的外連接? – 2012-03-01 17:17:21
順便說一下,'to_number(a.nums)'部分有什麼意義? – Martin 2012-03-01 19:06:36