Skip to content

Commit 85b3d4f

Browse files
Merge pull request #28 from bedrock-python/feat/close-master-task-followups
Daylight saving, planner scale, query pruning and the 1.0 final report
2 parents 6721cc3 + 1245fd9 commit 85b3d4f

39 files changed

Lines changed: 1490 additions & 48 deletions

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,9 @@ service = PartitionLifecycleService(repo, metadata, locks, hooks=[ColdStorageHoo
248248

249249
- [Getting started](https://bedrock-python.github.io/pg-partsmith/getting-started/installation/) — install, your first partitioned table, running it in production, a multi-tenant event store
250250
- [Concepts](https://bedrock-python.github.io/pg-partsmith/concepts/overview/) — how it works: schemes, boundaries, lifecycle policies, the plan, ownership, executing DDL, leaf backends
251-
- [How-to guides](https://bedrock-python.github.io/pg-partsmith/guide/configuration/) — scheduling, monitoring, backfilling, partitioning an existing table, migrating from pg_partman, changing a scheme, archiving, foreign keys, cold tiering, troubleshooting, recipes
251+
- [How-to guides](https://bedrock-python.github.io/pg-partsmith/guide/configuration/) — scheduling, monitoring, querying, backfilling, partitioning an existing table, migrating from pg_partman, changing a scheme, archiving, foreign keys, cold tiering, troubleshooting, recipes
252252
- [Reference](https://bedrock-python.github.io/pg-partsmith/reference/) — the API, every configuration field, every finding and error
253-
- [Design](https://bedrock-python.github.io/pg-partsmith/design/rfc-0001-partition-schemes/) — RFC 0001, the OSS research, PostgreSQL semantics verified on real servers
253+
- [Design](https://bedrock-python.github.io/pg-partsmith/design/rfc-0001-partition-schemes/) — RFC 0001, the OSS research, PostgreSQL semantics verified on real servers, and the final report on what 1.0 changed
254254
- [For AI agents](https://bedrock-python.github.io/pg-partsmith/agents/) — the whole API
255255
surface, the rules that break code when broken and a map of the rest, on one page to hand
256256
to a coding assistant

‎docs/agents.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ Constructor options worth knowing:
117117
* `RedisDistributedLockManager(redis_client, prefix=…, ttl_seconds=300, acquire_min_interval_seconds=0.0)`
118118
— needs the `redis-locks` extra; renews itself while long DDL runs.
119119

120+
`marker_prefix` must be the same on the repository and the provider — the first writes the
121+
ownership marker, the second finds it — and `PartitionLifecycleService` refuses a pair that
122+
disagrees. The provider's `boundary_codec` and `ddl_timezone` are used by
123+
`is_partition_closed` alone, which also takes `boundaries=config.time_boundaries` and reads
124+
both from there instead.
125+
120126
## Configuration
121127

122128
`TablePartitionConfig` is a frozen Pydantic model with `extra="forbid"`: an unknown keyword
@@ -394,6 +400,7 @@ Fetch a page when the task is the one named beside it.
394400
| [Configure a table](guide/configuration.md) | picking between the flat and composed forms |
395401
| [Schedule maintenance](guide/scheduling.md) | cron, APScheduler, Celery, Kubernetes |
396402
| [Monitor and alert](guide/monitoring.md) | turning results and issues into metrics |
403+
| [Query a partitioned table](guide/querying.md) | what prunes, what does not, encoded keys |
397404
| [Backfill partitions](guide/backfill.md) | giving existing data its windows |
398405
| [Partition an existing table](guide/partition-existing-table.md) | the DEFAULT-attach migration, `partition_data` |
399406
| [Migrate from pg_partman](guide/migration.md) | adopting a tree another tool built |
@@ -412,4 +419,5 @@ Fetch a page when the task is the one named beside it.
412419
| [Glossary](reference/glossary.md) | a term used here without explanation |
413420
| [PostgreSQL semantics](design/postgresql-semantics.md) | why a refusal exists — verified server behaviour |
414421
| [RFC 0001](design/rfc-0001-partition-schemes.md) | the design of schemes and lifecycle policies |
422+
| [Final report](design/final-report.md) | what 1.0 changed, the migration matrix per project, what is not covered |
415423
| [Changelog](changelog.md) | what changed between versions |

‎docs/concepts/boundaries.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ bound against the cutoff, and ownership compares it against the grid; a codec th
143143
only encode would create partitions the library could never recognise again.
144144

145145
`PostgresMetadataProvider(engine, boundary_codec=…)` needs the codec only for
146-
`is_partition_closed`; planning decodes through the configuration.
146+
`is_partition_closed`; planning decodes through the configuration. That one call also
147+
accepts the boundaries directly — `is_partition_closed(name, boundaries=config.time_boundaries)`
148+
— which is the way to be sure the reader and the writer agree about both the codec and the
149+
timezone.
147150

148151
## Cursors, in one place
149152

‎docs/concepts/overview.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ The [glossary](../reference/glossary.md) lists every term with links.
123123
- **Not a scheduler.** It runs when you call it. Cron, Celery, APScheduler, a CronJob, a
124124
start-up hook — any of them.
125125
- **Not a query rewriter.** Partition pruning depends on your queries constraining the
126-
partition key; the codec helps you compute the bounds, nothing more.
126+
partition key; the codec helps you compute the bounds, nothing more. See
127+
[Query a partitioned table](../guide/querying.md).
127128
- **Not an extension.** Plain SQL through SQLAlchemy, as the table's owner. Nothing to
128129
install in the database.
129130
- **Not a schema migration tool.** It creates, attaches, detaches and drops partitions of a

‎docs/concepts/ownership.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ repo = PostgresPartitionRepository(engine, marker_prefix="app")
8282
metadata = PostgresMetadataProvider(engine, marker_prefix="app")
8383
```
8484

85-
Pass the same prefix to both.
85+
Pass the same prefix to both — the repository stamps the marker, the metadata provider
86+
looks for it, and a partition detached under one prefix is invisible to the other, so it
87+
would simply never be dropped. `PartitionLifecycleService` refuses a pair that disagrees
88+
when it is constructed rather than letting the orphans pile up quietly. (A custom
89+
repository or provider that declares no prefix is trusted and not checked.)
8690

8791
## Revalidation before anything destructive
8892

‎docs/concepts/plan.md‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Operations are typed, ordered as they must execute, and nested where order matte
3030
| `CreatePartition` | create a partition, build its subtree, attach it | `parent_name`, `bounds`, `partition_by` (for a branch), `children`, `counts_as` |
3131
| `AttachPartition` | re-attach a detached orphan whose window is wanted again | `parent_name`, `bounds` |
3232
| `DetachPartition` | detach an expired partition, subtree included | `parent_name`, `mode`, `oid` |
33-
| `DropPartition` | drop a detached, marker-tagged orphan | `oid`, `detached_at`, `follows_detach` |
33+
| `DropPartition` | drop a detached, marker-tagged orphan | `oid`, `detached_at`, `follows_detach`, `bounds` |
3434

3535
Creations come first (each with its subtree inside it), then re-attachments, then
3636
detaches, then drops. Every operation records:
@@ -125,5 +125,27 @@ What the planner does with each state it can meet, in one table:
125125
| a partition pending an interrupted `DETACH CONCURRENTLY` | complete the detach with `FINALIZE` (`detach_finalize`); report it (`detach_pending`, INFO) |
126126
| a wanted name held by a relation with other bounds, or over 63 bytes | report (`name_unusable`) |
127127

128-
A converged tree produces no operation at all, so a tick against it costs one catalog
129-
read and no DDL.
128+
A converged tree produces no operation at all, so a tick against it costs the catalog
129+
reads below and no DDL.
130+
131+
## What a plan costs
132+
133+
Planning itself is a pure function over the configuration and the tree: it never queries
134+
the database, and it is linear in the number of nodes. Reading the tree is a fixed number
135+
of statements, whatever the table's size:
136+
137+
| Step | Statements | Grows with the tree? |
138+
|---|---|---|
139+
| the whole tree — every level, bounds, `relkind`, oids | 1 | no |
140+
| detached orphans and their markers | 1 | no |
141+
| sizes and row estimates | 1, and only when a policy asks for them | no |
142+
143+
There is no query per partition anywhere in the path. Facts are measured for lifecycle
144+
units only — the partitions retention decides over — so a nested tree does not multiply
145+
them: 2 000 monthly branches with eight buckets each are 2 000 targets, not 16 000.
146+
147+
For scale, a table of 18 001 nodes (2 000 monthly branches × 8 hash buckets, fifty years
148+
of history) plans in roughly 0.15 s on a developer machine, and a converged one plans to a
149+
no-op. Both the statement counts and a loose time budget are pinned by
150+
`tests/unit/test_scale.py`, so a planner that turned quadratic would fail the suite rather
151+
than a maintenance window.

0 commit comments

Comments
 (0)