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
+21-17
Original file line number
Diff line number
Diff line change
@@ -195,6 +195,7 @@ create_parent(
195
195
, p_template_table text DEFAULT NULL
196
196
, p_jobmon boolean DEFAULT true
197
197
, p_date_trunc_interval text DEFAULT NULL
198
+
, p_control_not_null boolean DEFAULT true
198
199
, p_time_encoder text DEFAULT NULL
199
200
, p_time_decoder text DEFAULT NULL
200
201
)
@@ -219,26 +220,29 @@ RETURNS boolean
219
220
*`p_template_table` - If you do not pass a value here, a template table will automatically be made for you in same schema that pg_partman was installed to. If you pre-create a template table and pass its name here, then the initial child tables will obtain these properties discussed in the **About** section immediately.
220
221
*`p_jobmon` - allow `pg_partman` to use the `pg_jobmon` extension to monitor that partitioning is working correctly. Defaults to TRUE.
221
222
* `p_date_trunc_interval` - By default, pg_partman's time-based partitioning will truncate the child table starting values to line up at the beginning of typical boundaries (midnight for daily, day 1 for monthly, Jan 1 for yearly, etc). If a partitioning interval that does not fall on those boundaries is desired, this option may be required to ensure the child table has the expected boundaries (especially if you also set `p_start_partition`). The valid values allowed for this parameter are the interval values accepted by PostgreSQL's built-in `date_trunc()` function (day, week, month, etc). For example, if you set a 9-week interval, by default pg_partman would truncate the tables by month (since the interval is greater than one month but less than 1 year) and unexpectedly start on the first of the month in some cases. Set this parameter value to `week`, so that the child table start values are properly truncated on a weekly basis to line up with the 9-week interval. If you are using a custom time interval, please experiment with this option to get the expected set of child tables you desire or use a more typical partitioning interval to simplify partition management.
222
-
*`p_time_encoder` - name of function that encodes a timestamp into a string representing your partition bounds. Setting this implicitly enables time based partitioning and is mandatory for text/uuid control column types. This enables paritioning tables using time based identifiers like uuidv7, ulid, snowflake ids and others. The function must handle NULL input safely. See test-time-daily.sql and test-uuid-daily for usage examples.
223
-
*`p_time_decoder` - name of function that decodes a text/uuid control value into a timestamp. Setting this implicitly enables time based partitioning and is mandatory for text/uuid control column types. This enables paritioning tables using time based identifiers like uuidv7, ulid, snowflake ids and others. The function must handle NULL input safely. See test-time-daily.sql and test-uuid-daily for usage examples.
223
+
*`p_control_not_null` - By default, this value is true and the control column must be set to NOT NULL. Setting this to false allows the control column to be NULL. Allowing this is not advised without very careful review and an explicit use-case defined as it can cause excessive data in the DEFAULT child partition.
224
+
*`p_time_encoder` - name of function that encodes a timestamp into a string representing your partition bounds. Setting this implicitly enables time based partitioning and is mandatory for text/uuid control column types. This enables partitioning tables using time based identifiers like uuidv7, ulid, snowflake ids and others. The function must handle NULL input safely. See test-time-daily.sql and test-uuid-daily for usage examples.
225
+
*`p_time_decoder` - name of function that decodes a text/uuid control value into a timestamp. Setting this implicitly enables time based partitioning and is mandatory for text/uuid control column types. This enables partitioning tables using time based identifiers like uuidv7, ulid, snowflake ids and others. The function must handle NULL input safely. See test-time-daily.sql and test-uuid-daily for usage examples.
224
226
225
227
226
228
<aid="create_sub_parent"></a>
227
229
```sql
228
230
create_sub_parent(
229
231
p_top_parent text
230
-
, p_declarative_check text DEFAULT NULL
231
232
, p_control text
232
233
, p_interval text
233
234
, p_type text DEFAULT 'range'
234
-
, p_epoch text DEFAULT 'none'
235
-
, p_premake int DEFAULT 4
236
-
, p_start_partition text DEFAULT NULL
237
235
, p_default_table boolean DEFAULT true
236
+
, p_declarative_check text DEFAULT NULL
238
237
, p_constraint_cols text[] DEFAULT NULL
238
+
, p_premake int DEFAULT 4
239
+
, p_start_partition text DEFAULT NULL
240
+
, p_epoch text DEFAULT 'none'
239
241
, p_jobmon boolean DEFAULT true
240
242
, p_date_trunc_interval text DEFAULT NULL
243
+
, p_control_not_null boolean DEFAULT true
241
244
, p_time_encoder text DEFAULT NULL
245
+
, p_time_decoder text DEFAULT NULL
242
246
)
243
247
RETURNS boolean
244
248
```
@@ -251,20 +255,19 @@ RETURNS boolean
251
255
* It is advised that you keep table names short for subpartition sets if you plan on relying on the table names for organization. The suffix added on to the end of a table name is always guaranteed to be there for whatever partition type is active for that set. Longer table names may cause the original parent table names to be truncated and possibly cut off the top level partitioning suffix. This cannot be controlled and ensures the lowest level partitioning suffix survives.
252
256
* Note that for the first level of subpartitions, the `p_parent_table` argument you originally gave to `create_parent()` would be the exact same value you give to `create_sub_parent()`. If you need further subpartitioning, you would then start giving `create_sub_parent()` a different value (the child tables of the top level partition set).
253
257
* The template table that is already set for the given p_top_parent will automatically be used.
254
-
*`p_time_encoder` - name of function that encodes a timestamp into a string representing your partition bounds. Setting this implicitly enables time based partitioning and is mandatory for text/uuid control column types. This enables paritioning tables using time based identifiers like uuidv7, ulid, snowflake ids and others. The function must handle NULL input safely. See test-time-daily.sql and test-uuid-daily for usage examples.
255
258
256
259
257
260
<aid="partition_data_time"></a>
258
261
```sql
259
262
partition_data_time(
260
-
p_parent_table text
261
-
, p_batch_count int DEFAULT 1
262
-
, p_batch_interval interval DEFAULT NULL
263
-
, p_lock_wait numeric DEFAULT 0
264
-
, p_order text DEFAULT 'ASC'
265
-
, p_analyze boolean DEFAULT true
266
-
, p_source_table text DEFAULT NULL
267
-
, p_ignored_columns text[] DEFAULT NULL
263
+
p_parent_table text
264
+
, p_batch_count int DEFAULT 1
265
+
, p_batch_interval interval DEFAULT NULL
266
+
, p_lock_wait numeric DEFAULT 0
267
+
, p_order text DEFAULT 'ASC'
268
+
, p_analyze boolean DEFAULT true
269
+
, p_source_table text DEFAULT NULL
270
+
, p_ignored_columns text[] DEFAULT NULL
268
271
)
269
272
RETURNS bigint
270
273
```
@@ -287,6 +290,7 @@ RETURNS bigint
287
290
<aid="partition_data_id"></a>
288
291
```sql
289
292
partition_data_id(p_parent_table text
293
+
p_parent_table text
290
294
, p_batch_count int DEFAULT 1
291
295
, p_batch_interval bigint DEFAULT NULL
292
296
, p_lock_wait numeric DEFAULT 0
@@ -321,8 +325,8 @@ partition_data_proc (
321
325
, p_interval text DEFAULT NULL
322
326
, p_lock_wait int DEFAULT 0
323
327
, p_lock_wait_tries int DEFAULT 10
324
-
, p_wait int DEFAULT 1, p_order text DEFAULT 'ASC'
0 commit comments