This was exactly what I needed to rank a large dataset. So happy to have found it!
I’m digging the ON DUPLICATE KEY UPDATE command. Seems like a better solution for the INSERT or UPDATE dilemma.
This tip came in very handy when trying to sort by a custom field in WordPress (I’m storing numerical values, but the field is varchar).