stopstalk / stopstalk-deployment

Stop stalking and start StopStalking :wink:
https://www.stopstalk.com
MIT License
311 stars 96 forks source link

Decrease page load time for Trending and Leaderboard page #23

Closed raj454raj closed 8 years ago

raj454raj commented 8 years ago

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.

raj454raj commented 8 years ago

We prefer page load optimization over code cosmetics ;)

raj454raj commented 8 years ago

https://github.com/stopstalk/stopstalk-deployment/blob/master/controllers/problems.py#L303 Remove this for loop and put SQL IN in the query

raj454raj commented 8 years ago

Store globally trending problems in a table and run a cron to update it?

raj454raj commented 8 years ago

Still some scope to improve time by removing sql query in loop

raj454raj commented 8 years ago

As the number of users are increasing - Leaderboard is slowing down.! Optimize fast.

raj454raj commented 8 years ago

Why compute everything on every pageload ? Cron to update a particular db table that stores the previous rating and other stuff?

raj454raj commented 8 years ago

Can find a query to get streak of a user - here

raj454raj commented 8 years ago

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 -

raj454raj commented 8 years ago

Next is to optimize LeaderBoard page, trending page done.

raj454raj commented 8 years ago

Deployment procedure for maintaining new columns of rating directly. 20160915_072744