Posted by petersprc on 05/28/07 00:43
On May 27, 12:10 pm, alpha.be...@googlemail.com wrote:
> I have a MySQL table of servers, I use RAND() to pick a random server
> to use each time, but how can I add a number to each server entry that
> allows it be to picked more often than the other 20 servers?
>
> For example Server1's weight is 80 and Server2's weight is 40 and
> hence Server1 is more likely to be picked than the others.
You could also do something like:
select serverId from server order by rand() / weight limit 1
[Back to original message]
|