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 f order by 1d_retain_rate desc limit 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 f order by 1d_retain_rate desc limit 0,50;
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。