首页 > 代码库 > Mysql in statement performance related with its position?
Mysql in statement performance related with its position?
select *from ( select event_date, ‘2014-12-06‘ as active_date, channel_id, new_user_count as new_user_count, 1d_retain/new_user_count as 1d_retain_rate from web_channel_retain where app_id=-1 and event_date=‘2014-12-05‘ and new_user_count>= 500 and channel_id in (select distinct channel_id from formated_channel_category where type_id=507 ) )as forder by 1d_retain_rate desclimit 0,50;
The above sql runs less than 2 seconds, while below sql runs a long time(I killed it before it completed). The only difference is the position of in statement.
select *from ( select event_date, ‘2014-12-06‘ as active_date, channel_id, new_user_count as new_user_count, 1d_retain/new_user_count as 1d_retain_rate from web_channel_retain where channel_id in (select distinct channel_id from formated_channel_category where type_id=507 ) and app_id=-1 and event_date=‘2014-12-05‘ and new_user_count>= 500 )as forder by 1d_retain_rate desclimit 0,50;
Mysql in statement performance related with its position?
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。