I am working on a project in which I need to rank websites in two way - Global rank and their rank in a particular country. There are various factors based on which both are calculated. There are ~200 countries for which rank needs to be calculated.
I am using MySQL
I have two questions -
Whenever any new website is added -
- Either I need to recalculate the ranks for all the website if I store the website rank in database. This requires a lot of processing each time a new website is added.
- or the other option is to assign a score to each website and whenever query is made assign rank by doing
order bybased on score, and returning its position. This doesn't seem scalable way as
order byis expensive operation.
Country Rank database and updation
How should I store per country rank of each website ?
How to update all these ranks when a new website is added ? Here the updation will be even more costly than in case of Global rank.
Should I generate it
on-the-flywhen queried and then cache the result ?
How do websites like play store show personalized and country based results ?