django-modelcluster
django-modelcluster copied to clipboard
Cluster TaggableManager is doing too much queries
I'm using a ClusterTaggableManager on a Wagtail project that I'm currently developing. I realized that using this Manager it performs a huge amount of queries when rendering templates,

while TaggableManager don't.
I've tried to replace get_queryset = get_query_set by get_queryset = _TaggableManager.get_query_set and it seems to work everything (I think) and don't perform that queries. I also saw that there is a comment in that function that begins with "FIXME". Why is this custom get_query_set method needed? Could be improved easily to not perform such amount of queries?
If you bypass ClusterTaggableManager's get_query_set method, it won't be able to pick up local changes to the tag field that aren't committed to the database. For Wagtail, this means that if you preview a page with a tag field, or view a draft version of it while a live version exists, it will show you the tags from the live version of the page.
Ok, those are the scenarios that I didn't tried (I haven't thought about it, sorry). So, are you telling me that those amount of queries are needed in order to ClusterTaggableManager works as expected, right?
Not at all - I'm sure that method could be optimised to reduce the number of queries. It can't be eliminated entirely, though.
Hi @marctc ,
I'm facing the same issue. Were you able to optimize the performance?
Nope. I fact i didn't tried to optimize TBH