MTG / freesound

The Freesound website
https://freesound.org
GNU Affero General Public License v3.0
317 stars 88 forks source link

Speedup some Django admin pages #1066

Closed ffont closed 6 years ago

ffont commented 6 years ago

Django admin pages are super slow, specially for the tables with high number of entries (e.g. Sounds, Users). As an admin, I want a fast server response when browsing Sounds and Users admin pages, including list view and individual views.

The list of pages that should be optimized:

@andrebola already suggested that the individual user page can be improved by removing the permissions section. We can remove that, but then we need to add an action to turn users into moderators (and possibly to remove moderator permissions as well).

The individual sound page is probably already fast so there is not much problem with it. The ones needing more love are probably the list ones.

andrebola commented 6 years ago

Regarding users list, the problem is the pagination (the query that counts all the users), this could be changed by using a custom paginator, but also there will be a better solution in newer versions of django: https://code.djangoproject.com/ticket/8408

About the list of sounds, if I remove the columns user and license then the page loads very fast.

andrebola commented 6 years ago

Note that for user form I only removed the individual permissions but the group permissions widget is still there

ffont commented 6 years ago

Note that for user form I only removed the individual permissions but the group permissions widget is still there

Cool, so then we don't need the make moderator buttons. Where was this change made?

Regarding the count problem I think we can't count yet on the future solution because we don't know when it will happen. Let's have a custom paginator for the admin and add a comment which mentions this Django issue and add a note to our "upgrading django version" wiki page to look for this when we upload. Let's use the paginator both in the users list view and the sounds list view. For the sounds case, why removing this columns makes it much faster? Are we missing select related somewhere? Maybe it can be added.

andrebola commented 6 years ago

here: https://github.com/MTG/freesound/pull/1069/files

andrebola commented 6 years ago

I think the slow part on sounds list is the join in the query with the table of license and users, so it's not a problem of select related because is one single query that takes too much time (maybe a index is missing?)

andrebola commented 6 years ago

We decided to remove the permissions widget from the admin, but we have to make sure we have groups for each permission. For this @ffont made this list of action to take:

andrebola commented 6 years ago

I created the document with this info, the permissions only affect a small number of users so I think we can do this changes manually.

https://docs.google.com/a/upf.edu/document/d/1m2cg9CHT-BZq4K33IVKpSnAA4db9TZyyWgfhieteRT8/edit?usp=sharing