mercredi 30 juin 2021

how to get random rows from mysql table without using RAND()?

i have a huge table with more then 350k records (products). I want to pick random 8 products from it but when try to use RAND() function with SQL, query got very slow. The RAND() function is too slow and consumes too much CPU.

SELECT name,deg_id,cat_image from products where status=1 order by rand() LIMIT 8

So I need alternate of RAND() function. Can someone else me to find an alternate?




Aucun commentaire:

Enregistrer un commentaire