Alban Hertroys writes:
Why not use EXISTS?DELETE FROM export_messages WHERE NOT EXISTS ( SELECT 1 FROM exports WHERE exports.export_id = export_messages.export_id )
Didn't think of it. Thanks for the code.
I suppose you run those queries in a transaction block, right?
Correct. Also I do a backup before doing the deletions. ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster