Is there a way to add retention on PostgreSQL? I've tried partitioning but seems to be a problem when querying between multiple partitioning regarding performance. This seemed to be a better way because you can delete one partition in a fast way then deleting few years of data.
Asked
Active
Viewed 7,142 times
1
-
First of all: do not ask two, loosely related questions in one SO post. Make them into two SO questions. Secondly: partitioning is a good approach. What exactly do you mean by performance problem? Did you measure how the performance degrades? – freakish May 06 '20 at 16:26
1 Answers
0
Partitioning is the king's way for getting rid of old data.
Most of your queries will get slightly slower, but that shouldn't be too bad if you use a moderate number of partitions.

Laurenz Albe
- 209,280
- 17
- 206
- 263
-
Partitioning can be done automatically? It is a tool that can do this? – Shagoon May 07 '20 at 07:33
-
There is `pg_partman`, but nothing out of the box. A simple `cron` job on the database server might do the trick. – Laurenz Albe May 07 '20 at 08:17