19

I have a table with approx. 200 million rows (approx. 0.5 TB) and I want to drop it, but it is taking a really long time.

It's been running for 2 days now. I suspect the rollback function to be the reason for this.

Is there a way to avoid the rollback function, so that I can speed this process up? I just want to get rid of the table, because the data in there are of no value any more.

0

1 Answer 1

35

You can list the running backends with

SELECT * FROM pg_stat_activity;

identify the process trying to rollback something which is working on this table.

Find its pid.

You can terminate a backend with the query SELECT pg_terminate_backend(64738), where 64738 is the pid column in your previous SELECT.

After that, you can likely DROP that table.

If even that won't work, then restart postgresql, but most likely it will.

2
  • 4
    I managed to kill a autovacuum task on the table, and then it dropped the table quick hereafter.
    – Pelle G
    Commented Sep 17, 2018 at 8:56
  • this answer is the bomb! Thank you!
    – diginoise
    Commented Feb 8 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.