whoisgregg - 10:20 pm on Sep 26, 2012 (gmt 0)
Random could really come back and bite you in this kind of system. Lead distribution is *very* important to salespeople. Like, lawsuit important.
I would recommend doing it like this:
1. Determine which salespeople are eligible to receive the lead.
2. Get the timestamp of the most recent lead that was assigned to each of those salespeople.
3. Assign the lead to the salesperson who has gone the longest without receiving a lead.
This should be efficient to query the database and an effective and fair way to distribute the leads in a way that will make sense to the users.