Using indexes in queries where the filter is made of 'OR'-ed expressions is suboptimal
We noticed that domains of the kind ['OR, ('a', '=', x), ('b.f1', '=', y)]
that result in an expression of the kind t.a = x OR t.id in (subquery)
could be more optimal if we used an UNION
of the two queries (because postgres can sometimes use an index but in my test even without indexes it's a bit more optimal).
The review implements this on Model.search
.