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
Copy file name to clipboardExpand all lines: doc/pg_partman.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -112,6 +112,11 @@ As a note for people that were not aware, you can name arguments in function cal
112
112
* p_parent_table - the existing parent table. MUST be schema qualified, even if in public schema.
113
113
* p_control - the column that the partitioning will be based on. Must be a time or integer based column.
114
114
* p_type - one of the following values to set the partitioning type that will be used:
115
+
+**native**
116
+
- Use the native partitioning methods that are built into PostgreSQL 10+.
117
+
- For PG11+, it is highly recommended that native partitioning be used over trigger-based partitioning. PG10 is still lacking significant features for native partitioning, so please see notes above for more info.
- Child table creation is kept up to date by running `run_maintenance(_proc)`. There is no trigger maintenance.
115
120
+**partman**
116
121
- Create a trigger-based partition set using pg_partman's method of partitioning.
117
122
- Whether it is time or serial based is determined by the control column's data type and if the p_epoch flag is set.
@@ -120,10 +125,6 @@ As a note for people that were not aware, you can name arguments in function cal
120
125
- Inserts to the parent table outside the optimize_trigger window will go to the proper child table if it exists, but performance will be degraded due to the higher overhead of handling that condition.
121
126
- If the child table does not exist for the value given, the row will go to the parent.
122
127
- Child table creation & trigger function is kept up to date by the `run_maintenance()` function.
123
-
+**native**
124
-
- Use the native partitioning methods that are built into PostgreSQL 10+.
125
-
- Provides significantly better write & read performance than "partman" partitioning, but does not have as much feature support. See notes above for more info.
126
-
- Child table creation is kept up to date by the `run_maintenance()`. There is no trigger maintenance.
127
128
*`p_interval` - the time or integer range interval for each partition. No matter the partitioning type, value must be given as text. The generic intervals of "yearly -> quarter-hour" are for time partitioning and giving one of these explicit values when using pg_partman's trigger-based partitioning will allow significantly better performance than using an arbitrary time interval. For native partitioning, any interval value is valid and will have the same performance which is always better than trigger-based.
128
129
+*yearly* - One partition per year
129
130
+*quarterly* - One partition per yearly quarter. Partitions are named as YYYYqQ (ex: 2012q4)
@@ -198,7 +199,8 @@ As a note for people that were not aware, you can name arguments in function cal
198
199
*`p_source_table` - This option can be used when you need to move data into a natively partitioned set. Pass a schema qualified tablename to this parameter and any data in that table will be MOVED to the partition set designated by p_parent_table, creating any child tables as needed.
199
200
* Returns the number of rows that were moved from the parent table to partitions. Returns zero when parent table is empty and partitioning is complete.
200
201
201
-
*`partition_data_proc (p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_source_table text DEFAULT NULL, p_order text DEFAULT 'ASC', p_lockwait int DEFAULT 0, p_lockwait_tries int DEFAULT 10, p_quiet boolean DEFAULT false)`*
202
+
203
+
*`partition_data_proc (p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_source_table text DEFAULT NULL, p_order text DEFAULT 'ASC', p_lock_wait int DEFAULT 0, p_lock_wait_tries int DEFAULT 10, p_quiet boolean DEFAULT false)`*
202
204
203
205
* A procedure that can partition data in distinct commit batches to avoid long running transactions and data contention issues.
204
206
* Only works with PostgreSQL 11+
@@ -209,6 +211,8 @@ As a note for people that were not aware, you can name arguments in function cal
209
211
*`p_wait` - Cause the procedure to pause for a given number of seconds between commits (batches) to reduce write load
210
212
*`p_source_table` - Same as the p_source_table option in the called partitioning function.
211
213
*`p_order` - Allows you to specify the order that data is migrated from the parent/default to the children, either ascending (ASC) or descending (DESC). Default is ASC.
214
+
*`p_lock_wait` - Parameter passed directly through to the underlying partition_data_*() function. Number of seconds to wait on rows that may be locked by another transaction. Default is to wait forever (0).
215
+
*`p_lock_wait_tries` - Parameter to set how many times the procedure will attempt waiting the amount of time set for p_lock_wait. Default is 10 tries.
212
216
*`p_quiet` - Procedures cannot return values, so by default it emmits NOTICE's to show progress. Set this option to silence these notices.
* For PG11+, this is the preferred method to run partition maintenance vs directly calling the run_maintenance() function.
271
-
* This procedure can be called instead of the `run_maintenance()` function to cause PostgreSQL to commit after each partition set's maintenance has finished. This reduces contention issues with long running transactions when there are many partition sets to maintain.
275
+
* This procedure can be called instead of the `run_maintenance()` function to cause PostgreSQL to commit after each partition set's maintenance has finished. This greatly reduces contention issues with long running transactions when there are many partition sets to maintain.
272
276
*`p_wait` - How many seconds to wait between each partition set's maintenance run. Defaults to 0.
273
277
*`p_analyze` - See p_analyze option in run_maintenance.
* Returns the number of partitions undone and the number of rows moved to the parent table. The partitions undone value returns -1 if a problem is encountered.
377
381
378
382
379
-
*`undo_partition_proc(p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_target_table text DEFAULT NULL, p_keep_table boolean DEFAULT true, p_lockwait int DEFAULT 0, p_lockwait_tries int DEFAULT 10, p_quiet boolean DEFAULT false)`*
383
+
*`@extschema@.undo_partition_proc(p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_target_table text DEFAULT NULL, p_keep_table boolean DEFAULT true, p_lock_wait int DEFAULT 0, p_lock_wait_tries int DEFAULT 10, p_quiet boolean DEFAULT false)`*
380
384
381
385
* A procedure that can un-partition data in distinct commit batches to avoid long running transactions and data contention issues.
*`p_wait` - Cause the procedure to pause for a given number of seconds between commits (batches) to reduce write load
388
392
*`p_target_table` - Same as the p_target_table option in the undo_partition() function.
389
393
*`p_keep_table` - Same as the p_keep_table option in the undo_partition() function.
394
+
*`p_lock_wait` - Parameter passed directly through to the underlying partition_data_*() function. Number of seconds to wait on rows that may be locked by another transaction. Default is to wait forever (0).
395
+
*`p_lock_wait_tries` - Parameter to set how many times the procedure will attempt waiting the amount of time set for p_lock_wait. Default is 10 tries.
390
396
*`p_quiet` - Procedures cannot return values, so by default it emmits NOTICE's to show progress. Set this option to silence these notices.
Copy file name to clipboardExpand all lines: updates/pg_partman--3.2.1--4.0.0.sql
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ IF current_setting('server_version_num')::int >= 110000 THEN
68
68
69
69
-- Syntax check during extension updating doesn't even allow the CREATE PROCEDURE statement to exist. Using dollar quoting w/ EXECUTE to get around it in this conditional IF block.
70
70
v_partition_data_sql := $partition_data$
71
-
CREATE PROCEDURE @[email protected]_data_proc (p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_source_table text DEFAULT NULL, p_order text DEFAULT 'ASC', p_lockwaitint DEFAULT 0, p_lockwait_triesint DEFAULT 10, p_quiet boolean DEFAULT false)
71
+
CREATE PROCEDURE @[email protected]_data_proc (p_parent_table text, p_interval text DEFAULT NULL, p_batch int DEFAULT NULL, p_wait int DEFAULT 1, p_source_table text DEFAULT NULL, p_order text DEFAULT 'ASC', p_lock_waitint DEFAULT 0, p_lock_wait_triesint DEFAULT 10, p_quiet boolean DEFAULT false)
0 commit comments