> DELETE FROM B > WHERE r_id IN (SELECT R.id > FROM R, B > WHERE r.end_date < (NOW() - (interval '1 day' * 30)) > AND r.id = b.r_id > How about: DELETE FROM B WHERE r_id IN (SELECT distinct R.id FROM R WHERE r.end_date < (NOW() - (interval '1 day' * 30)) ? Greetings Marcin -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance