Christian Fritze <The(dot)Finn(at)sprawl(dot)de> writes:
> explain select * from allmain where exists (select distinct
> dokids_as_int from allslwfull where dokids_as_int = idn and
> wort_nouml_lower like 'gen%')
Try dropping the "distinct" on the inner select. As a moment's thought
will reveal, it's not buying you anything; and it's costing you sort
and unique passes over the subplan result.
regards, tom lane