- return queryset.filter(tag_relations__tag__in=tags
- ).annotate(count=models.Count('pk')).filter(count=len(tags))
+ # Multiple joins are WAY faster than having-count, at least on Postgres 9.1.
+ for tag in tags:
+ queryset = queryset.filter(tag_relations__tag=tag)
+ return queryset