2011-12-16 65 views
0

插入記錄我已經SQL查詢,如:當提交記錄時,我們是從其他表

insert into dedupunclear 
    select mdnnumber,poivalue 
    from deduporiginal a 
    where exists (
    select 1 
    from deduporiginal 
    where mdnnumber=a.mdnnumber and rowid<a.rowid) 
    or mdnnumber is null; 

有500K記錄在我的deduporiginal。我已經把這個查詢放在函數中,但是它需要大約3個小時才能將記錄提交到dedupunclear表。

有解決性能問題的方法嗎?

當此查詢提交記錄時,在某個時間間隔或從select查詢得到所有結果後?

+0

要清理已經提交的部分結果的數據有多困難? – Thilo 2011-12-16 07:15:39

回答

1

我這是怎麼了另日:

delete from table a 
    where rowid > 
      (select min(rowid) from table b 
       where nvl(a.id, 'x') = nvl(b.id, 'x') ) 

而不是插入到重複數據刪除的表,我只是直接從分段表中刪除的行。對於有100萬行的表格,這個查詢工作得很好。我擔心nvl函數會殺死索引,但它運行得很好。