I have a SQL query like this:
SELECT `users`.`name`, `users`.`username`, `users`.`bio`, `users`.`city`, `users`.`photo`
FROM (`onlines`) JOIN `users`
ON `onlines`.`username`=`users`.`username`
WHERE `users`.`offline_status` = 0
AND `users`.`perma_ban` = 0
AND `users`.`is_premium` = 1
GROUP BY `onlines`.`username`
ORDER BY RAND() LIMIT 27
I am using RAND but I am not happy with performance. How can I optimize this query?
I read this:
How can i optimize MySQL's ORDER BY RAND() function?
But I am using inner join, so this question didn't help me.