event_extra
次の自己結合クエリを作成したいくつかの条件に基づいて重複を見つけるために、as and on という名前のテーブルがありますが、レコードがそれ以上 (100 万) になると、多くの時間がかかります。
テーブルフィールドは次のとおりです
evt_id
extra1
extra2
extra3
extra4
extra5
extra6
extra7
extra8
extra9
このテーブルにはUnique index
がありevt_id
ます。
自己結合クエリ
select cde1.evt_id,
cde1.extra1,
cde1.extra2,
cde1.extra3,
cde1.extra4,
cde1.extra5,
cde1.extra6,
cde2.evt_id as evt_id2,
cde1.extra7,
cde1.extra8,
cde1.extra9,
from event_extra cde2
join event_extra cde1
on (( cde1.extra4 = cde2.extra4 and cde1.extra7 = cde2.extra7) or
(cde1.extra4 = cde2.extra5 and cde1.extra7 = cde2.extra8) or
(cde1.extra4 = cde2.extra6 and cde1.extra7 = cde2.extra9) or
(cde1.extra5 = cde2.extra4 and cde1.extra8 = cde2.extra7) or
(cde1.extra5 = cde2.extra5 and cde1.extra8 = cde2.extra8) or
(cde1.extra5 = cde2.extra6 and cde1.extra8 = cde2.extra9) or
(cde1.extra6 = cde2.extra4 and cde1.extra9 = cde2.extra7) or
(cde1.extra6 = cde2.extra5 and cde1.extra9 = cde2.extra8) or
(cde1.extra6 = cde2.extra6 and cde1.extra9 = cde2.extra9))
and ((to_number(cde1.extra3) >= to_number(cde2.extra1) and
(to_number(cde1.extra3) <= to_number(cde2.extra2))) or
((to_number(cde1.extra1) >= to_number(cde2.extra2)) and
(to_number(cde1.extra1) <= to_number(cde2.extra3))) or
((to_number(cde1.extra2) >= to_number(cde2.extra1)) and
(to_number(cde1.extra2) <= to_number(cde2.extra3))))
and cde1.evt_id > cde2.evt_id
order by cde1.evt_id;
上記のクエリのパフォーマンスを向上させるために利用できる他のアプローチはありますか?
Database Version: Oracle11g