Christian Fritze <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html