select tbl1.* 
from tbl_rjyls_today tbl1
where not exists (select key from tbl_yscc tbl2 
                  where tbl1.key=tbl2.key 
                    and tbl2.jyrq = '20060517')功能:取出存在表tbl1中而不存在于tbl2中的记录,tbl1中6W多条,tbl2中60w条

解决方案 »

  1.   

    这么多数据,估计用exists速度也很慢,看看有没有索引,但估计不会快多少
      

  2.   

    select tbl0.* 
    from tbl_rjyls_today tbl0
    minus
    select tbl1.* 
    from tbl_rjyls_today tbl1,tbl_yscc tbl2 
    where tbl1.key=tbl2.key and tbl2.jyrq = '20060517'
      

  3.   

    minus慢,看看tbl2.jyrq 上有没有索引
      

  4.   

    select tbl1.* 
    from tbl_rjyls_today tbl1
    where tbl1.key=tbl2.key(+) 
    and tbl1.jyrq = '20060517' and
    tbl2.key is null
      

  5.   

    在orcale里面最好不要使用null。因为如果使用,该条件的索引将不能使用。