I have a seemingly simple delete:
DELETE FROM table WHERE added_at < '2017-08-14'
on a table with ~20k rows (w ~10k affected rows), but it has been running for 2000+ seconds.
SELECT * FROM table WHERE added_at < '2017-08-14'
takes a few ms.
I have a few other tables with FOREIGN KEY
s pointing to this id
and I had some previous records pointing to it, but they have already been deleted.
I have tried to:
- check if the table is locked using the answer in https://stackoverflow.com/a/26596931/2171758
- terminate all backends
VACUUM