in查询优化

select 
   ai.act_name 
from act_info ai 
where
  ai.act_id in 
    (select DISTINCT(object_id) 
      from rel_base_recomm 
    where work_type = 1)

in优化: 在in的内层包装一张表 :

select
  ai.act_name 
from act_info ai
where
ai.act_id in 
  (select object_id 
      from( 
        select DISTINCT(object_id) 
        from rel_ba  se_recomm 
        where work_type = 1
       ) 
   as tmp )


这样可以优化in的查询速度

你可能感兴趣的:(in查询优化)