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
Performs HASH partitioning for `relation` by partitioning expression `expr`. 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()`).
Stops a background worker performing a concurrent partitioning task. Note: worker will exit after it finishes relocating a current batch.
182
182
183
183
### Triggers
184
-
```plpgsql
185
-
create_update_triggers(parent REGCLASS)
186
-
```
187
-
Creates a for-each-row trigger to enable cross-partition UPDATE on a table partitioned by HASH/RANGE. The trigger is not created automatically because of the overhead caused by its function. You don't have to use this feature unless partitioning key might change during an UPDATE.
184
+
185
+
Triggers are no longer required nor for INSERTs, neither for cross-partition UPDATEs. However, user-supplied triggers *are supported*.
186
+
187
+
Each inserted row results in execution of BEFORE/AFTER INSERT trigger functions of a **corresponding partition**.
188
+
Each updated row results in execution of BEFORE/AFTER UPDATE trigger functions of a **corresponding partition**.
189
+
Each moved row (cross-partition update) results in execution of BEFORE UPDATE + BEFORE/AFTER DELETE + BEFORE/AFTER INSERT trigger functions of **corresponding partitions**.
188
190
189
191
### Post-creation partition management
190
192
```plpgsql
@@ -196,9 +198,10 @@ Replaces specified partition of HASH-partitioned table with another table. The `
196
198
197
199
198
200
```plpgsql
199
-
split_range_partition(partition REGCLASS,
200
-
split_value ANYELEMENT,
201
-
partition_name TEXT DEFAULT NULL)
201
+
split_range_partition(partition_relid REGCLASS,
202
+
split_value ANYELEMENT,
203
+
partition_name TEXT DEFAULT NULL,
204
+
tablespace TEXT DEFAULT NULL)
202
205
```
203
206
Split RANGE `partition` in two by `split_value`. Partition creation callback is invoked for a new partition if available.
Merge several adjacent RANGE partitions. Partitions are automatically ordered by increasing bounds; all the data will be accumulated in the first partition.
209
212
210
213
```plpgsql
211
-
append_range_partition(parent REGCLASS,
214
+
append_range_partition(parent_relid REGCLASS,
212
215
partition_name TEXT DEFAULT NULL,
213
216
tablespace TEXT DEFAULT NULL)
214
217
```
215
218
Append new RANGE partition with `pathman_config.range_interval` as interval.
216
219
217
220
```plpgsql
218
-
prepend_range_partition(parent REGCLASS,
221
+
prepend_range_partition(parent_relid REGCLASS,
219
222
partition_name TEXT DEFAULT NULL,
220
223
tablespace TEXT DEFAULT NULL)
221
224
```
222
225
Prepend new RANGE partition with `pathman_config.range_interval` as interval.
Drop RANGE partition and all of its data if `delete_data` is true.
237
240
238
241
```plpgsql
239
-
attach_range_partition(relation REGCLASS,
240
-
partition REGCLASS,
241
-
start_value ANYELEMENT,
242
-
end_value ANYELEMENT)
242
+
attach_range_partition(parent_relid REGCLASS,
243
+
partition_relid REGCLASS,
244
+
start_value ANYELEMENT,
245
+
end_value ANYELEMENT)
243
246
```
244
247
Attach partition to the existing RANGE-partitioned relation. The attached table must have exactly the same structure as the parent table, including the dropped columns. Partition creation callback is invoked if set (see `pathman_config_params`).
245
248
246
249
```plpgsql
247
-
detach_range_partition(partition REGCLASS)
250
+
detach_range_partition(partition_relid REGCLASS)
248
251
```
249
252
Detach partition from the existing RANGE-partitioned relation.
250
253
251
254
```plpgsql
252
-
disable_pathman_for(relation TEXT)
255
+
disable_pathman_for(parent_relid REGCLASS)
253
256
```
254
257
Permanently disable `pg_pathman` partitioning mechanism for the specified parent table and remove the insert trigger if it exists. All partitions and data remain unchanged.
255
258
256
259
```plpgsql
257
-
drop_partitions(parent REGCLASS,
258
-
delete_data BOOLEAN DEFAULT FALSE)
260
+
drop_partitions(parent_relid REGCLASS,
261
+
delete_data BOOLEAN DEFAULT FALSE)
259
262
```
260
263
Drop partitions of the `parent` table (both foreign and local relations). If `delete_data` is `false`, the data is copied to the parent table first. Default is `false`.
261
264
@@ -347,7 +350,7 @@ CREATE TABLE IF NOT EXISTS pathman_config_params (
347
350
partrel REGCLASS NOT NULLPRIMARY KEY,
348
351
enable_parent BOOLEANNOT NULL DEFAULT TRUE,
349
352
auto BOOLEANNOT NULL DEFAULT TRUE,
350
-
init_callback REGPROCEDURE NOT NULLDEFAULT 0,
353
+
init_callback TEXTDEFAULT NULL,
351
354
spawn_using_bgw BOOLEANNOT NULL DEFAULT FALSE);
352
355
```
353
356
This table stores optional parameters which override standard behavior.
@@ -414,6 +417,7 @@ Shows memory consumption of various caches.
414
417
-`RuntimeAppend` (overrides `Append` plan node)
415
418
-`RuntimeMergeAppend` (overrides `MergeAppend` plan node)
416
419
-`PartitionFilter` (drop-in replacement for INSERT triggers)
`PartitionRouter` is another *proxy node* used in conjunction with `PartitionFilter` to enable cross-partition UPDATEs (i.e. when you update any column of a partitioning key). Since this node has a great deal of side effects (ordinary `UPDATE` becomes slower; cross-partition `UPDATE` is transformed into `DELETE + INSERT`), it is disabled by default. To enable it, refer to the list of [GUCs](#disabling-pg_pathman) below.
`RuntimeAppend` and `RuntimeMergeAppend` have much in common: they come in handy in a case when WHERE condition takes form of:
434
454
```
435
455
VARIABLE OP PARAM
@@ -580,7 +600,7 @@ NOTICE: 100 rows copied from part_test_2
580
600
(3 rows)
581
601
```
582
602
583
-
- You can turn foreign tables into partitions using the `attach_range_partition()` function. Rows that were meant to be inserted into parent will be redirected to foreign partitions (as usual, PartitionFilter will be involved), though by default it is prohibited to insert rows into partitions provided not by `postgres_fdw`. Only superuser is allowed to set `pg_pathman.insert_into_fdw` GUC variable.
603
+
- You can turn foreign tables into partitions using the `attach_range_partition()` function. Rows that were meant to be inserted into parent will be redirected to foreign partitions (as usual, PartitionFilter will be involved), though by default it is prohibited to insert rows into partitions provided not by `postgres_fdw`. Only superuser is allowed to set `pg_pathman.insert_into_fdw`[GUC](#disabling-pg_pathman) variable.
584
604
585
605
### HASH partitioning
586
606
Consider an example of HASH partitioning. First create a table with some integer column:
@@ -710,7 +730,8 @@ There are several user-accessible [GUC](https://www.postgresql.org/docs/9.5/stat
0 commit comments