Use random () to get the random number of data, but the result is not close to 1 2?

There are 1000 pieces of data in the

user_default_avatar table, but the result of the query is always greater than 500 instead of floating around 500?

select *
from user_default_avatar
order by rand()
limit 100;
Nov.03,2021

well, in fact, it has something to do with the id distribution density of the data. If the later number distribution density is large, it will result in a number greater than 1 answer 2.


this algorithm is not more efficient than the one you have been scolded. Aren't you afraid of being scolded again?
both methods need to calculate a random number for each row, and your new statement may not be as fast as before.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eb7540-2645.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eb7540-2645.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?