About
PostgreSQL doesn't reclaim physical space upon deleting all records from a table
  • 17 May 2023
  • 494 words
  • 2 min read
Undredal, Norway
Undredal, Norway

There are scenarios where it becomes necessary to periodically delete all the data from a table.

To achieve this, you can use either DELETE or TRUNCATE operation. The DELETE operation may be more favorable, especially if there are frequent queries against the table that is being cleaned up. In such cases, data is removed without waiting for all transactions to complete, allowing ongoing transactions to still access the data even after it has been marked for deletion.