Try to rewrite the query into:
SELECT b.rid
FROM mza_movie_upload a
INNER JOIN mza_movie_statics b
ON a.id=b.rid
WHERE a.status= '1' and b.download= '1'
-- group by b.rid order by sum(b.download) desc;
GROUP BY b.rid ORDER BY count(*) DESC;
In this query SELECT a.id
is replaced by SELECT b.rid
, and is 100% equivalent to the oryginal query because of JOIN ... ON a.id=b.rid
predicate, but leads MySql to slighly better plan
And, as @Dennis Leon sugested, a.status= '1' and b.download= '1'
are compared to strings, not numbers.
Try also to replace order by sum(b.download) desc
with order by count(*) desc
- since the query retrieves only rows with b.download = '1', then sum( b.download )
is equivalent to count(*)
- this change allows to save a few hundreds miliseconds on conversion from strings to numbers within SUM( .. )
.
In the end create two indexes:
create index bbbb on mza_movie_statics( download, rid );
create index aaaaa on mza_movie_upload( status );
then try the query speed after above changes.