Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not create partitions that are not to be retained #649

Open
nicolagi opened this issue Apr 11, 2024 · 0 comments
Open

Do not create partitions that are not to be retained #649

nicolagi opened this issue Apr 11, 2024 · 0 comments

Comments

@nicolagi
Copy link

Suppose retention is set to 4 months for a monthly partitioned table foo.

Suppose run_maintenance fails to run for whatever reason and as a consequence foo has only a very old partition, say, foo_p20010101.
When run_maintenance runs again in 2024 it will create lots of partitions.
The vast majority of them will be expired at the subsequent run.

Would it make sense to not create those in the first place?
Perhaps the timestamp to start creating partitions from should be something like MAX(NOW() - retention, last_partition_timestamp)?

nicolagi added a commit to nicolagi/pg_partman that referenced this issue Apr 11, 2024
I realized this requires tests and possibly other changes, but it's just a start to make the proposal from the pgpartman#649 more concrete.
I did try this and works for my use case.
@keithf4 keithf4 self-assigned this Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants