I have quite a large table with 19 000 000 records, and I have problem with duplicate rows. There\'s a lot of similar questions even here in SO, but none of them seems to gi
UPDATE table SET datetime = null
WHERE location_id IN (
SELECT location_id
FROM table as tableBis
WHERE tableBis.location_id = table.location_id
AND table.datetime > tableBis.datetime)
SELECT * INTO tableCopyWithNoDuplicate FROM table WHERE datetime is not null
DROp TABLE table
RENAME tableCopyWithNoDuplicate to table
So you keep the line with the lower datetime. I'm not sure about perf, it depends on your table column, your server etc...