Closed raj454raj closed 8 years ago
We prefer page load optimization over code cosmetics ;)
https://github.com/stopstalk/stopstalk-deployment/blob/master/controllers/problems.py#L303
Remove this for loop and put SQL IN
in the query
Store globally trending problems in a table and run a cron to update it?
Still some scope to improve time by removing sql query in loop
As the number of users are increasing - Leaderboard is slowing down.! Optimize fast.
Why compute everything on every pageload ? Cron to update a particular db table that stores the previous rating and other stuff?
Leaderboard page - This query is taking most of the time. Calculate this result in cron and create a SQL VIEW
.
When should we update the VIEW
-
Next is to optimize LeaderBoard page, trending page done.
Deployment procedure for maintaining new columns of rating directly.
Important observation: We have to query submission table without any condition. Why make a db query every time
compute_row
is called, instead keep a dictionary and pass the list of submissions to compute_row corresponding to the user.