-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
Problem
Let's say I've got the following partitioning manager
manager = PostgresPartitioningManager(
[
PostgresPartitioningConfig(
model=MyModel,
strategy=PostgresCurrentTimePartitioningStrategy(
size=PostgresTimePartitionSize(months=1),
count=2,
max_age=relativedelta(months=1),
),
),
]
)running pgpartition at 17.11.2025 12:00 UTC results in folowing partitions to be created
python manage.py pgpartition --defer-attach --detach=concurrently
MyModel:
+ 2025_nov (deferred attach)
name: 2025_nov
from_values: 2025-11-01 12:00:00
to_values: 2025-12-01 12:00:00
size_unit: months
size_value: 1
+ 2025_dec (deferred attach)
name: 2025_dec
from_values: 2025-12-01 12:00:00
to_values: 2026-01-01 12:00:00
size_unit: months
size_value: 1
Now let's skip time to 18.12.2025 08:00 UTC and run the same command to see the results
MyModel:
- 2025_nov
name: 2025_nov
from_values: 2025-11-01 08:00:00
to_values: 2025-12-01 08:00:00
size_unit: months
size_value: 1
+ 2026_jan (deferred attach)
name: 2026_jan
from_values: 2026-01-01 08:00:00
to_values: 2026-02-01 08:00:00
size_unit: months
size_value: 1
~ 2025_nov (detached concurrently)
name: 2025_nov
from_values: 2025-11-01 08:00:00
to_values: 2025-12-01 08:00:00
size_unit: months
size_value: 1
As we see the partition with _jan suffix is overlapping with the previously created one for dec.
Alternatively if we skip time to 18.12.2025 16:00 UTC the results are following
MyModel:
- 2025_nov
name: 2025_nov
from_values: 2025-11-01 16:00:00
to_values: 2025-12-01 16:00:00
size_unit: months
size_value: 1
+ 2026_jan (deferred attach)
name: 2026_jan
from_values: 2026-01-01 16:00:00
to_values: 2026-02-01 16:00:00
size_unit: months
size_value: 1
~ 2025_nov (detached concurrently)
name: 2025_nov
from_values: 2025-11-01 16:00:00
to_values: 2025-12-01 16:00:00
size_unit: months
size_value: 1
now the _jan partition starts at 16:00, while the previous one ends at 12:00 so we have 4 hour hole in our table.
Expectations
I'd expect the partition ranges to be aligned to 00:00 when using monthly-sized ranges.
Metadata
Metadata
Assignees
Labels
No labels