I have to pick 30 random records from a table, except that the query uses one second, and this slows mysql if the content is displayed by many users. This is the query:
SELECT relationship, COUNT(id) AS number FROM FR_user_friends GROUP BY relationship ORDER BY rand() LIMIT 30
Do you know how to speed up this query? Thank you.
If I remove rand() the query is fast. We have to find an alternative for rand()