A faster solution is
DELETE FROM dups a USING (
SELECT MIN(ctid) as ctid, key
FROM dups
GROUP BY key HAVING COUNT(*) > 1
) b
WHERE a.key = b.key
AND a.ctid <> b.ctid
More Related Contents:
- How to list table foreign keys
- Two SQL LEFT JOINS produce incorrect result
- Postgresql GROUP_CONCAT equivalent?
- How to update selected rows with values from a CSV file in Postgres?
- What is the maximum number of columns in a PostgreSQL select query
- Humanized or natural number sorting of mixed word-and-number strings
- Pass multiple values in single parameter
- Custom SERIAL / autoincrement per group of values
- How do I determine the last day of the previous month using PostgreSQL?
- PL/pgSQL checking if a row exists
- postgres column “X” does not exist
- Multiple CTE in single query
- Return pre-UPDATE column values using SQL only
- SQL syntax term for ‘WHERE (col1, col2) < (val1, val2)'
- PostgreSQL: encoding problems on Windows when using psql command line utility
- Get the distinct sum of a joined table column
- How much disk-space is needed to store a NULL value using postgresql DB?
- Aggregate a single column in query with many columns
- Aggregating (x,y) coordinate point clouds in PostgreSQL
- PostgreSQL convert columns to rows? Transpose?
- Does Postgres support nested or autonomous transactions?
- PostgreSQL delete with inner join
- Regular expression in PostgreSQL LIKE clause
- Why is iterating through a large Django QuerySet consuming massive amounts of memory?
- Update a column of a table with a column of another table in PostgreSQL
- Check if NULL exists in Postgres array
- Generate DEFAULT values in a CTE UPSERT using PostgreSQL 9.3
- PostgreSQL: Full Text Search – How to search partial words?
- Temporal database design, with a twist (live vs draft rows)
- PostgreSQL – dynamic value as table name [duplicate]