My SQL script scans ~7000 records and retrieves 100 of them randomly, also pulls correlative data from an additional table (via SQL JOIN). My server response time is extremely slow using this code (>7 seconds).
ROUND(AVG(r.rank),0) AS avrank,
COUNT(r.rank) AS countrank
FROM stories s
LEFT JOIN ratings
AS r
ON r.storyidr = s.id
GROUP BY s.id
ORDER BY RAND()
LIMIT 100";
I was wondering if someone could make a recommendation on something I could do to improve my response time, and increase page speed. Thank you in advance.