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

Already on GitHub? Sign in to your account

Performance improvement in bulk_lookup_kwargs() #86

Merged
merged 1 commit into from Mar 25, 2013

Conversation

Projects
None yet
2 participants
Contributor

vdboor commented Oct 15, 2011

Hi,

When passing a QuerySet to bulk_lookup_kwargs(), the queryset was undesirably executed to get a list of IDs. This fix turns that into a nice 'object_id IN (SELECT ..)' query instead. In a real life app with a large set of objects, the difference in performance is noticeable.

Greetings,
Diederik

@vdboor vdboor Optimize the query in `bulk_lookup_kwargs` for QuerySet args.
When passing a QuerySet to bulk_lookup_kwargs(), the queryset was
undesirably executed to get a list of IDs. This causes an unnecessary
performance loss.

There is no need to loop over a QuerySet to execute a IN (1, 3, 4) query.
Instead, just allow the ORM and database to execute a IN (SELECT id FROM ..) query.
In a real life app with a large set of objects, the difference in performance is noticeable.
5a9338a

@xordoquy xordoquy referenced this pull request Mar 13, 2013

Closed

Roadmap for django-taggit #112

@apollo13 apollo13 merged commit 5a9338a into alex:master Mar 25, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment