Leaderboard Slow to Load

I have noticed that the leaderboards seem to be very slow to load.

Like recently I timed it and it took about 5 seconds for the weekly German leaderboard to load, and then 12 seconds for the all-time one to load. The problem seems to have steadily gotten worse over the past couple years.

If this is an issue with load / heavy usage of the website, maybe this could be solved by having a cached value for the points that is not updated in real-time, and then the system could manually update the entry of the user who is checking the leaderboard at the time. Then have the cached field with a standard btree index in the database, or something like that…this whole setup would have minimal load on the server but would make the leaderboards display nearly-instantly. At least that’s how I’d try to solve this!