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
@@ -77,14 +78,29 @@ Done! Now it's time to setup your partitioning schemes.
77
78
78
79
> **Important:** Don't forget to set the `PG_CONFIG` variable in case you want to test `pg_pathman` on a custom build of PostgreSQL. Read more [here](https://wiki.postgresql.org/wiki/Building_and_Installing_PostgreSQL_Extension_Modules).
79
80
81
+
## How to update
82
+
In order to update pg_pathman:
83
+
84
+
1. Install the latest _stable_ release of pg_pathman.
85
+
2. Restart your PostgreSQL cluster.
86
+
3. Execute the following queries:
87
+
88
+
```plpgsql
89
+
/* replace X.Y with the version number, e.g. 1.3 */
90
+
ALTER EXTENSION pg_pathman UPDATE TO "X.Y";
91
+
SETpg_pathman.enable= t;
92
+
```
93
+
80
94
## Available functions
81
95
82
96
### Partition creation
83
97
```plpgsql
84
98
create_hash_partitions(relation REGCLASS,
85
99
attribute TEXT,
86
100
partitions_count INTEGER,
87
-
partition_data BOOLEAN DEFAULT TRUE)
101
+
partition_data BOOLEAN DEFAULT TRUE,
102
+
partition_names TEXT[] DEFAULT NULL,
103
+
tablespaces TEXT[] DEFAULT NULL)
88
104
```
89
105
Performs HASH partitioning for `relation` by integer key `attribute`. The `partitions_count` parameter specifies the number of partitions to create; it cannot be changed afterwards. If `partition_data` is `true` then all the data will be automatically copied from the parent table to partitions. Note that data migration may took a while to finish and the table will be locked until transaction commits. See `partition_table_concurrently()` for a lock-free way to migrate data. Partition creation callback is invoked for each partition if set beforehand (see `set_init_callback()`).
Performs RANGE partitioning for `relation` by partitioning key `attribute`.`start_value` argument specifies initial value, `interval` sets the range of values in a single partition, `count` is the number of premade partitions (if not set then pathman tries to determine it based on attribute values). Partition creation callback is invoked for each partition if set beforehand.
122
+
Performs RANGE partitioning for `relation` by partitioning key `attribute`,`start_value` argument specifies initial value, `p_interval` sets the default range for auto created partitions or partitions created with `append_range_partition()` or `prepend_range_partition()` (if `NULL` then auto partition creation feature won't work), `p_count` is the number of premade partitions (if not set then `pg_pathman` tries to determine it based on attribute values). Partition creation callback is invoked for each partition if set beforehand.
107
123
108
124
```plpgsql
109
125
create_partitions_from_range(relation REGCLASS,
@@ -148,9 +164,9 @@ Same as above, but for a RANGE-partitioned table.
148
164
149
165
### Post-creation partition management
150
166
```plpgsql
151
-
replace_hash_partition(old_partition REGCLASS,
152
-
new_partition REGCLASS,
153
-
lock_parent BOOL DEFAULT TRUE)
167
+
replace_hash_partition(old_partition REGCLASS,
168
+
new_partition REGCLASS,
169
+
lock_parent BOOL DEFAULT TRUE)
154
170
```
155
171
Replaces specified partition of HASH-partitioned table with another table. The `lock_parent` parameter will prevent any INSERT/UPDATE/ALTER TABLE queries to parent table.
Merge two adjacent RANGE partitions. First, data from `partition2` is copied to `partition1`, then `partition2` is removed.
169
185
186
+
```plpgsql
187
+
merge_range_partitions(partitions REGCLASS[])
188
+
```
189
+
Merge several adjacent RANGE partitions (partitions must be specified in ascending or descending order). All the data will be accumulated in the first partition.
Create new RANGE partition for `relation` with specified range bounds.
212
+
Create new RANGE partition for `relation` with specified range bounds. If `start_value` or `end_value` are NULL then corresponding range bound will be infinite.
@@ -222,6 +243,12 @@ Drop partitions of the `parent` table (both foreign and local relations). If `de
222
243
223
244
### Additional parameters
224
245
246
+
247
+
```plpgsql
248
+
set_interval(relation REGCLASS, value ANYELEMENT)
249
+
```
250
+
Update RANGE partitioned table interval. Note that interval must not be negative and it must not be trivial, i.e. its value should be greater than zero for numeric types, at least 1 microsecond for `TIMESTAMP` and at least 1 day for `DATE`.
251
+
225
252
```plpgsql
226
253
set_enable_parent(relation REGCLASS, value BOOLEAN)
227
254
```
@@ -240,17 +267,21 @@ Set partition creation callback to be invoked for each attached or created parti
240
267
/* RANGE-partitioned table abc (child abc_4) */
241
268
{
242
269
"parent": "abc",
270
+
"parent_schema": "public",
243
271
"parttype": "2",
244
272
"partition": "abc_4",
273
+
"partition_schema": "public",
245
274
"range_max": "401",
246
275
"range_min": "301"
247
276
}
248
277
249
278
/* HASH-partitioned table abc (child abc_0) */
250
279
{
251
280
"parent": "abc",
281
+
"parent_schema": "public",
252
282
"parttype": "1",
253
283
"partition": "abc_0"
284
+
"partition_schema": "public"
254
285
}
255
286
```
256
287
@@ -641,3 +672,4 @@ Do not hesitate to post your issues, questions and new ideas at the [issues](htt
641
672
Ildar Musin <i.musin@postgrespro.ru> Postgres Professional Ltd., Russia
642
673
Alexander Korotkov <a.korotkov@postgrespro.ru> Postgres Professional Ltd., Russia
643
674
Dmitry Ivanov <d.ivanov@postgrespro.ru> Postgres Professional Ltd., Russia
0 commit comments