Dear PostgresQL Experts,
I am trying to get to the bottom of some efficiency problems and hope that
you can help. The difficulty seems to be with INTERSECT expressions.
I have a query of the form
select A from T where C1 intersect select A from T where C2;
It runs in about 100 ms.
But it
I asked:
select A from T where C1 intersect select A from T where C2;
select A from T where C1 and C2;
[why isn't the first optimised into the second?]
Stephan Szabo answered:
Given a non-unique A, C1 as B5, c2 as C5 and the data:
A | B | C
1 | 6 | 1
1 | 1 | 6
The intersect gives 1 row,