0

I'm developing a Spring application that connects to a PostgreSQL database. In my tables, I have some items that are time-based (has a timestamp column) and I want to define a keep-time for these items in an application.properties file. Any items that are older than the specified keep-time should be deleted. Any help/suggestions on how I could go about implementing this would be appreciated.

Edmond
  • 615
  • 1
  • 5
  • 15

1 Answers1

0

You could look into partitioning the table.

Partitioning with PostgreSQL is not straightforward, as there is no DML support before PostgreSQL v10 and it lacks features like global indexes, but it would be much easier to remove old data by dropping a partition than by running a mass DELETE.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263