I'd like to do something like this in postgres
select * from table t where t.one = 11 AND t.two = 12 and t.three = 13
union all
select * from table t where t.one = 21 AND t.two = 22 and t.three = 23
I tried join lateral
and inner join
s but the performance is too bad. So I need to union all
these queries but I don't want just to concat an indefinate amount of these values, Is there something like these https://stackoverflow.com/a/55484168/1321514 for postgres?
I don't see the need for a UNION at all. And I don't understand how a JOIN would help here
Your query is equivalent to:
select *
from table t
where (t.one,t.two,t.three) in ( (11,12,13), (21,22,23) );
Alternatively you can try joining to a VALUES clause:
select t.*
from table t
join (
values (11,12,13), (21,22,23)
) as x(c1,c2,c3) on t.one = x.c1
and t.two = x.c2
and t.three = x.c3;