in reply to Implementation of a Ladder System


A somewhat different approach.

Let's generate the ladder off a mysql database on the fly and update on the fly.
I'd have one table with all the user info (name, etc.) and a ladder table with two fields, user_id and ladder.
:ladder_table +------------+-------------+ | Field | Type | +------------+-------------+ | user_id | smallint(6) | | ladder_id | smallint(6) | +------------+-------------+


When you have a situation where user_id 0034 (current ladder ranking of 2345) beats user_id 0638 (current_ladder ranking of 7) you know that the only users who will be affected are those whose ladder ranking is between 7 and 2345.

You can do this in three sql calls.

Your first sql call would clear the winner out of the way.
DELETE from ladder_table where ladder_id = 2345

Then you need to determine how many user_id 0638 is going to fall (through whatever method you come up with). I am going to assume this user is falling ten rankings for this example. This will be necessity shove everyone from ladder_ranking 17 to ladder_ranking 2344 down as well.
UPDATE ladder_table SET ladder_ranking = ladder_ranking -1 WHERE ladder_ranking >= 17 AND ladder_ranking < 2345

The last one is the call setting your user_id 0034 to the ranking of 7.

UPDATE ladder_table SET ladder_ranking = 7 WHERE user_id = 0034


Those calls should be very fast in most cases.
Thanks,

EEjack