Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin view: opening a tag takes forever #194

Open
cfaessler opened this issue May 9, 2014 · 1 comment
Open

Admin view: opening a tag takes forever #194

cfaessler opened this issue May 9, 2014 · 1 comment

Comments

@cfaessler
Copy link

opening a tag in the admin view takes forever, e.g: http://localhost:8000/admin/swid/tag/2213/
@dbrgn can you investigate on this?

@dbrgn
Copy link
Member

dbrgn commented May 12, 2014

Yes, the reason for this is that a huge amount of SQL queries are being done. For example for brasero-common: 11830 queries in 1109.7ms.

This is due to the file and session select boxes. Each entry causes a few lookups in the database due to the __unicode__ implementation.

If you have the debug toolbar enabled, it will do an EXPLAIN query for each regular query, which makes the loading even far far slower than without the toolbar. Especially on SQLite. On my system loading one of the tags took 60s instead of 5s.

The question is how to handle this. For example the file representation does a query to the directory model, in order to show the full path. We could remove this information, but then files cannot really be identified in the admin.

A better way would be to prefetch all related objects in a single query (by JOINing the file and directory tables). That would probably solve the problem. The downside: A litlte hack is needed: https://stackoverflow.com/questions/15563259/django-prefetch-when-listing-objects-in-admin

I think we should try to do that optimization, but with low prio.

@dbrgn dbrgn assigned cfaessler and unassigned dbrgn May 12, 2014
@cfaessler cfaessler removed their assignment May 24, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants