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.
Asked
Active
Viewed 636 times
0
-
cron the job that will check and delete those?. – Vao Tsun May 02 '17 at 09:46
-
Yeah my initial thought was to create a scheduled task in Spring to do this. – Edmond May 02 '17 at 10:09
1 Answers
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
-
This seems too complicated for what I need, but I will look into it anyway thanks. – Edmond May 02 '17 at 10:17