如何自定义此查询,大约需要30秒才能取出结果,并在'视频'该表大约有50万,会员和会员中有300万会员。表,是否有任何备用查询或我应该在2个选择查询中中断此查询?
user_id已编入索引 vid_id已编入索引
select a.ref_url , a.source , a.video_name , a.viewers , b.username ,
c.points from
members_videos a
inner join Members b on a.user_id = b.user_id
inner join rankings c on c.user_id = b.user_id
where a.cat_ids in (123,234,52,234,423,122) not in (110,99)
order by a.vid_id Desc limit 10
答案 0 :(得分:0)
有多种因素:
替代,尝试子查询。
SELECT *
FROM
(
select a.ref_url , a.source , a.video_name , a.viewers , b.username ,
c.points from
members_videos a
inner join Members b on a.user_id = b.user_id
inner join rankings c on c.user_id = b.user_id
where a.cat_ids in (123,234,52,234,423,122) not in (110,99)
) as T
order by T.vid_id Desc limit 10