2011-12-16 67 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函数会杀死索引,但它运行得很好。