postgresql 9.1 - Django QuerySet changing IN to ANY(array[...]) -


We have found some slow-moving queries in our DB and I think that by changing some of them to the original SQL can be solved.

Looking at the following:

  Model.obies FILTER (rel_id__in = [1,2,3])   

Output (

  select all, from field "model" WHERE ("rel_id" I want to convert the SQL to:  
  select all, field "model" (<, 2, 2))   

From WHERE ("rel_id" = any (array [1, 2, 2]))

I know that this can not be an optimum approach, but EXPLIN analysis Gives very little data from the second query.

So my question is,

possible This can be done like this:

  Model.objects.extra (where = {'rel_id "= any (array% s)'% (str (your_list)))) < / Code>  

Other you might want to resort to using.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -