select *   from log_rate_cloc a
 where exists
 (select 1
          from log_rate_cloc b
         where a.raw_file_name = b.raw_file_name
           and b.raw_FILE_NAME LIKE '%CLOCC1%0609010015000001%');
           
           
           
           
           select *   from log_rate_cloc a
 where  a.raw_file_name in
 (select b.raw_FILE_NAME
          from log_rate_cloc b
         where  b.raw_FILE_NAME LIKE '%CLOCC1%0609010015000001%');

解决方案 »

  1.   

    索引是做了的吧?exists之所以被提倡,就是因为它可以用到索引。
      

  2.   

    两个where的条件不一样,没有可比性
      

  3.   

    in 是从符合条件的数据开始找,excists 是从不符合条件的数据开始找。如果你想找的数据在所有的数据中只占很少的一部分,你用excists就是属于大海捞针了。^_^
      

  4.   

    好好看看oracle的sql performance文档~ 
    oracle举了两个例子说明什么时候用in, 什么时候用exists  ...
      

  5.   

    首先需要有索引
    两个不一样的。看你是条件的集合比较大还是选取的部分比较大。条件集合小的话用in比较快。反之exists
    好比,选取数据部分有100万。条件集合有1000。各么肯定in要快。反之亦然