SQLテクノロジーの内幕-10 inとexistsのパフォーマンス比較

911 ワード

in exists

in         hash   , exists     loop  ,  loop          。

      exists in           。

            ,   in exists    。



          ,     ,        exists,       in:



  : A(  ), B(  )

1:

select * from A where cc in (select cc from B)

   ,   A  cc    ;

select * from A where exists(select cc from B where cc=A.cc)

   ,   B  cc    。

   

2:

select * from B where cc in (select cc from A)

   ,   B  cc    ;

select * from B where exists(select cc from A where cc=B.cc)

   ,   A  cc    。

not in  not exists

         not in             ,      ;

 not extsts               。

        , not exists  not in  。



in   =   



select name from student where name in ('zhang','wang','li','zhao');



 



select name from student where name='zhang' or name='li' or name='wang' or name='zhao'



       。