老大,这怎么知道,写出来sql语句,还要看索引哦

解决方案 »

  1.   

    用no exists 代替 not in 可能会好一点,再就是建索引
      

  2.   

    Not in用不到索引,最好能用外联接替换
      

  3.   

    尽量不要使用NOT IN子句。使用MINUS 子句都比NOT IN 子句快,虽然使用MINUS子句要进行两次查询: 
      select staff_name from staff_member where staff_id in (select staff_id from staff_member MINUS select staff_id from staff_func where func_id like ‘81%’);
      

  4.   

    把sql帖出来看看!
    not in会使索引失效,从而导致全表扫描.