In Django it's common to do the following
MyModel.objects.filter(id__in=[huge array])
However it's not very efficient as described in the following answer here: https://dba.stackexchange.com/questions/91247/optimizing-a-postgres-query-with-a-large-in
What would be a good way of replicating the above answer in Django given that you are using the ORM. Or would you have to drop down to raw sql for the entire query.
What I'm looking for is if you have a queryset, is there a good way of joining that queryset with a temporary table that you created (possibly in raw sql).
from Using join of temporary table as an alternative of `IN` in Django
No comments:
Post a Comment