Phyton Using join of temporary table as an alternative of `IN` in Django python using join,python string concatenation using join,python using

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).

Answer:1



  1. python using join
  2. python string concatenation using join
  3. python using os.path.join
  4. list to string python using join

Are Decimal dtypes available in numpy? >>> import decimal, numpy >>> d = decimal.Decimal('1.1') >>> s = [['123.123','23'],['2323.212','123123.21312']] >>> ss = ...

Are Decimal dtypes available in numpy? >>> import decimal, numpy >>> d = decimal.Decimal('1.1') >>> s = [['123.123','23'],['2323.212','123123.21312']] >>> ss = ...

For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How ...

For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How ...