Leaderboard
by The Tank Man on The Tank Man 1684157134227 |
The leaderboard page used to take 10+ seconds to load, but now is actually usable. My plan with this leaderboard page now is to start at the top and go down, writing a post about each interesting player. So in the end there will be a sort of annotated leaderboard. Not that I'm going to force myself to write about every player - someone like luger is already a pro and I don't have anything in particular to say about him. I want to focus more on interesting soloq players like tony top. People who maybe are known in NA soloq but not as well known outside it, or are known for a specific champion or playstyle.
For this post, read on if you're interested in what the problem was with the leaderboard. It was taking 10+ seconds to load. Pause and guess why (hint: it gets the top 100 players, and their league, tier, lp, name, and posts on them, to put in the table you see)
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Answer: the query getting the top 100 players from the database was slow because it had no index on LP/ladder rank.
This uses django with a player model, which was ordered by a player's lp (lp plus league/tier, so diamond 2 50lp < diamond 1 49 lp), but had no index on lp. So with an index on lp, the query to get the first 100 players by lp is much faster. Player query time wasn't a problem when the number of players in the database was small, but became one as it grew.
This sort of thing seems trivial and obvious in hindsight, and maybe your first instinct should be to find a slow query and see what index it uses or should use, but figuring out what was going on with the database as well as changing it took me a while.
Hopefully now that this is done I can do more visibile features - stuff like colorful kdas, filtering match history by champions/players, graphs of winrate by gold and time, finishing match timeline details, etc. Plus write posts about players on the leaderboard.
Although now that I'm writing posts on the players on the first page, it seems like the first page takes almost 2s to load, whereas other pages take like .2s, so getting the posts might be slow too... |
|
by thetankman 1684181448318 |
|
hooray! |
|
by paige 1684377317686 |
0