You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INFO:partition:Table dogs planned SQL: ALTER TABLE `dogs` REORGANIZE PARTITION `p_20201204` INTO (PARTITION `p_20210422` VALUES LESS THAN (221), PARTITION `p_20210522` VALUES LESS THAN MAXVALUE);
41
+
42
+
dogs:
43
+
sql: ALTER TABLE `dogs` REORGANIZE PARTITION `p_20201204` INTO (PARTITION `p_20210422` VALUES LESS THAN (221), PARTITION `p_20210522` VALUES LESS THAN MAXVALUE);
44
+
noop: True
45
+
```
46
+
47
+
### Running `partman` in your development environment
DEBUG:root:Partition range column identified as id
23
60
DEBUG:root:Found partition before = (100)
24
61
DEBUG:root:Found tail partition named p_20201204
25
62
INFO:root:No-op mode
26
63
27
64
ALTER TABLE `dbname`.`tablename` REORGANIZE PARTITION `p_20201204` INTO (PARTITION `p_20201204` VALUES LESS THAN (3101009), PARTITION `p_20210122` VALUES LESS THAN MAXVALUE);
28
-
29
65
```
30
66
31
-
You can also use a yaml configuration file with the `--config` parameter of the form:
67
+
## Configuration
68
+
You can use a yaml configuration file with the `--config` parameter of the form:
69
+
32
70
```yaml
33
71
partitionmanager:
34
72
dburl: sql://user:password@localhost/db-name
@@ -48,6 +86,7 @@ partitionmanager:
48
86
table3:
49
87
retention:
50
88
days: 14
89
+
table4: {}
51
90
```
52
91
53
92
For tables which are either partitioned but not yet using this tool's schema, or which have no empty partitions, the `bootstrap` command can be useful for proposing alterations to run manually. Note that `bootstrap` proposes commands that are likely to require partial copies of each table, so likely they will require a maintenance period.
@@ -63,12 +102,20 @@ INFO:calculate_sql_alters:Reading prior state information
- ALTER TABLE `orders` REORGANIZE PARTITION `p_20210405` INTO (PARTITION `p_20210416` VALUES LESS THAN (30901), PARTITION `p_20210516` VALUES LESS THAN (630449), PARTITION `p_20210615` VALUES LESS THAN MAXVALUE);
66
-
67
105
```
68
106
69
-
# Algorithm
107
+
## Getting started
108
+
109
+
### Configuring `partman`
110
+
111
+
- At start, if any configuration file specified as a CLI argument, read that configuration file to set all other values.
112
+
- Then, process all remaining command line arguments, overriding values loaded from the configuration file in case of conflicts.
113
+
- From those command-line arguments, determine whether to collect statistics `stats`, determine an initial partition layout `bootstrap`, or operate in the normal `maintain` mode.
114
+
- Use the configuration information as inputs to the required algorithm.
70
115
71
-
The core algorithm is implemented in a method `plan_partition_changes` in `table_append_partition.py`. That algorithm is:
116
+
### How does `partman` determine when an additional partition is needed?
117
+
118
+
The core algorithm is implemented in a method `get_pending_sql_reorganize_partition_commands` in `table_append_partition.py`. That algorithm is:
72
119
73
120
For a given table and that table's intended partition period, desired end-state is to have:
74
121
- All the existing partitions containing data,
@@ -105,9 +152,17 @@ Procedure:
105
152
- Append the new partition to the intended empty partition list.
106
153
- Return the lists of non-empty partitions, the current empty partitions, and the post-algorithm intended empty partitions.
107
154
108
-
# TODOs
155
+
#### How do I run `partman` in `noop` mode?
156
+
157
+
The results of the algorithm are converted into `ALTER` statements; if the user configured `--noop` they're emitted to console and the logs for each table. If not set to `--noop`, the application will execute the ALTERs at the database server and emit the results, including execution time as prometheus statistics if so configured.
158
+
159
+
#### "Bootstrap" algorithm
160
+
161
+
The bootstrap mode is a limited form of the "Maintain" Algorithm, using a temporary state file to determine rates-of-change. The bootstrap mode also does not limit itself to only affecting empty partitions, it can and will request changes that will prompt row copies, in order to prepare a table for future use of the "Maintain" algorithm.
162
+
163
+
## TODOs
109
164
110
165
Lots:
111
-
[X] Support for tables with partitions across multiple columns.
112
-
[] A drop mechanism, for one. Initially it should take a retention period and log proposed `DROP` statements, not perform them.
113
-
[] Yet more tests, particularly live integration tests with a test DB.
166
+
-[x] Support for tables with partitions across multiple columns.
167
+
-[ ] A drop mechanism, for one. Initially it should take a retention period and log proposed `DROP` statements, not perform them.
168
+
-[ ] Yet more tests, particularly live integration tests with a test DB.
0 commit comments