mysql left join 优化 大表驱动小表 小表驱动大表

SELECT s.id,s.nick,s.userId,s.sid,s.session_key,s.retoke,s.shouquantime,s.refresh_token_timeout,s.timezone,t.endtime
from  taobao_session as s 
LEFT JOIN   taobao_productrepost_set as t
on t.memberId=s.sid 
where  1 
and s.sid<>'' 
and (s.refresh_token_timeout<=0  or s.refresh_token_timeout>=unix_timestamp(now()))
and s.sj_kaiguan=1 
order by t.reposttime asc,t.publishednum asc LIMIT 0,200

优化前  受影响的行: 0
时间: 11.123ms

 

SELECT s.id,s.nick,s.userId,s.sid,s.session_key,s.retoke,s.shouquantime,s.refresh_token_timeout,s.timezone,t.endtime
from  taobao_productrepost_set as t
LEFT JOIN     taobao_session as s 
on t.memberId=s.sid 
where  1 
and s.sid<>'' 
and (s.refresh_token_timeout<=0  or s.refresh_token_timeout>=unix_timestamp(now()))
and s.sj_kaiguan=1 
order by t.reposttime asc,t.publishednum asc LIMIT 0,200

优化后 受影响的行: 0
时间: 0.025ms

 

DELETE  t,i FROM `taobao_custom_trade` as t join taobao_custom_trade_item as i on t.tid=i.tid where t.sellerUserId ='';

联合删除

 

你可能感兴趣的:(mysql left join 优化 大表驱动小表 小表驱动大表)