PostgreSQL Fix Duplicates in Database
This usually happens when bringing a Site from Dev to Live. There is a easy fix for this though that has never let me down.
EG: Duplicates are in Table articles. We access PostgreSQL DB with psql database_name than we execute below to get rid of the duplicates.
DELETE FROM articles a WHERE a.ctid <> (SELECT min(b.ctid) FROM articles b WHERE a.id = b.id);
34 seconds