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 -
Global rank
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 by
based on score, and returning its position. This doesn't seem scalable way asorder by
is 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-fly
when queried and then cache the result ?
How do websites like play store show personalized and country based results ?