I can think of two ways to approach this problem:
First approach: Update in batches:
- Sort the scores, obtain the ranking
- Divide the players by rank into batches like player0-player999, player1000-player1999, etc
- For each batch, delete entries in the existing table that conflict with the new data. This means deleting existing entries belonging to players in the current batch or who currently rank in the range of ranks being updated in the current batch. Then you load the ranking data for the batch into the database, and jump to the next batch after say 0.1s.
Second approach: New table
- Create (or truncate) a new table just like your existing ranking table.
- compute the new ranking and insert your data
- Swap the tables (after preferably locking them). This should take less than a second.