J
J
Jsman2019-07-01 13:17:23
PostgreSQL
Jsman, 2019-07-01 13:17:23

How to clear a table?

I have a table with 5,000,000 records and I ran the TRUNCATE table_name CASCADE command and ... this command has been running for 48 hours now?
Please tell us how to clean the table as quickly as possible and how to organize monitoring.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2019-07-01
@SeniorDmitry

If truncate is executed for more than a second, then truncate is not executed at all, but is waiting for a lock.
Look in pg_stat_activity where state != 'idle' for long running transactions.
Or immediately with a request for pg_locks, for example, like this: https://github.com/dataegret/pg-utils/blob/master/...
Normal monitoring is a separate, complex and sad issue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question