col1、col2にインデックスが存在する場合に有効。
◆改善前
select *
   from XXX
  where col1 = AAA
       or col2 = BBB
◆改善後
select *
   from (
             select * from XXX where col1 = AAA Union
             select * from XXX where col2 = BBB
            ) XXX
 
0 件のコメント:
コメントを投稿