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

Optimizing queryset for SingleTagField in an admin page #91

Open
johnyoonh opened this issue Jun 16, 2020 · 3 comments
Open

Optimizing queryset for SingleTagField in an admin page #91

johnyoonh opened this issue Jun 16, 2020 · 3 comments

Comments

@johnyoonh
Copy link

TagField is a Many-to-Many field, so prefetech_related works well to get all the tags together in a single query, but SingleTagField is a foreign field. Even when I use select_related, the duplicate queries are happening for each object in the queryset. Is there a way around this? I am surprised that nobody ever mentioned it. I don't think tagulous' admin mixin addresses this as it does not optimize queryset.

@johnyoonh
Copy link
Author

For now, switching to ForeignKey instead of SingleTagField fixes the select_related not working.

@johnyoonh
Copy link
Author

This also causes a quadratic query DB lookup when deleting and updating an object via admin page form.

@jedie
Copy link
Contributor

jedie commented Nov 23, 2021

Think in https://github.com/radiac/django-tagulous/blob/develop/tagulous/admin.py is nothing about optimizing the queryset, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

2 participants