On Thu, Nov 21, 2013 at 2:31 PM, desmodemone <desmodemone@xxxxxxxxx> wrote: > Hi Robert, could you try with "exists" ? > > SELECT c.* > FROM contacts c > WHERE exists ( SELECT 1 FROM phone p WHERE p.addr =? and > p.contact_id=c.id ) > OR exists (SELECT 1 FROM email e WHERE e.addr = ? and e.contact_id=c.id ); hm, how about: SELECT c.* FROM contacts c WHERE exists ( SELECT 1 FROM phone p WHERE p.addr =? AND p.contact_id=c.id UNION ALL SELECT 1 FROM email e WHERE e.addr = ? AND e.contact_id=c.id ); merlin -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance