Long list in queryset's __in lookup

9 views
Skip to first unread message

Le Hai Pham

unread,
Apr 23, 2020, 10:46:35 AM4/23/20
to Django users
Hi everyone,

I am having an issue with the queryset's __in lookup. The story is that we need to filter within a very long list. 
E.g.

users = User.objects.filter(id__in=long_list_uids).filter(**logic_conditions).

Since the long_list_uids is really long (Around 20k items), it will be ineffective to pass the list to the DB layer.
And there is no way to get the list directly from DB.

Put the logic aside, is there any way to improve this?
I am thinking about inheriting the QuerySet class to make to store multiple smaller queryset, but still acts like a normal Queryset. Is this possible?

Thanks in advance,
Reply all
Reply to author
Forward
0 new messages