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: README.md
+38-12
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,12 @@
7
7
8
8
The `pg_pathman` module provides optimized partitioning mechanism and functions to manage partitions.
9
9
10
-
The extension is compatible with PostgreSQL 9.5+.
10
+
The extension is compatible with:
11
+
* PostgreSQL 9.5, 9.6, 10;
12
+
* Postgres Pro Standard 9.5, 9.6;
13
+
* Postgres Pro Enterprise;
14
+
15
+
By the way, we have a growing Wiki [out there](https://github.com/postgrespro/pg_pathman/wiki);
11
16
12
17
## Overview
13
18
**Partitioning** means splitting one large table into smaller pieces. Each row in such table is moved to a single partition according to the partitioning key. PostgreSQL supports partitioning via table inheritance: each partition must be created as a child table with CHECK CONSTRAINT. For example:
@@ -41,6 +46,7 @@ More interesting features are yet to come. Stay tuned!
41
46
## Feature highlights
42
47
43
48
* HASH and RANGE partitioning schemes;
49
+
* Partitioning by expression and composite key;
44
50
* Both automatic and manual partition management;
45
51
* Support for integer, floating point, date and other types, including domains;
46
52
* Effective query planning for partitioned tables (JOINs, subselects etc);
@@ -55,9 +61,11 @@ More interesting features are yet to come. Stay tuned!
* Optimize hash join (both tables are partitioned by join key).
68
+
Take a look at [this page](https://github.com/postgrespro/pg_pathman/wiki/Roadmap);
61
69
62
70
## Installation guide
63
71
To install `pg_pathman`, execute this in the module's directory:
@@ -97,30 +105,30 @@ SET pg_pathman.enable = t;
97
105
### Partition creation
98
106
```plpgsql
99
107
create_hash_partitions(relation REGCLASS,
100
-
attributeTEXT,
108
+
expr TEXT,
101
109
partitions_count INTEGER,
102
110
partition_data BOOLEAN DEFAULT TRUE,
103
111
partition_names TEXT[] DEFAULT NULL,
104
112
tablespaces TEXT[] DEFAULT NULL)
105
113
```
106
-
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()`).
114
+
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()`).
107
115
108
116
```plpgsql
109
117
create_range_partitions(relation REGCLASS,
110
-
attributeTEXT,
118
+
expr TEXT,
111
119
start_value ANYELEMENT,
112
120
p_interval ANYELEMENT,
113
121
p_count INTEGER DEFAULT NULL
114
122
partition_data BOOLEAN DEFAULT TRUE)
115
123
116
124
create_range_partitions(relation REGCLASS,
117
-
attributeTEXT,
125
+
expr TEXT,
118
126
start_value ANYELEMENT,
119
127
p_interval INTERVAL,
120
128
p_count INTEGER DEFAULT NULL,
121
129
partition_data BOOLEAN DEFAULT TRUE)
122
130
```
123
-
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.
131
+
Performs RANGE partitioning for `relation` by partitioning expression `expr`, `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 expression's values). Partition creation callback is invoked for each partition if set beforehand.
124
132
125
133
126
134
### Data migration
@@ -141,7 +149,7 @@ Stops a background worker performing a concurrent partitioning task. Note: worke
141
149
```plpgsql
142
150
create_hash_update_trigger(parent REGCLASS)
143
151
```
144
-
Creates the trigger on UPDATE for HASH partitions. The UPDATE trigger isn't created by default because of the overhead. It's useful in cases when the key attribute might change.
152
+
Creates the trigger on UPDATE for HASH partitions. The UPDATE trigger isn't created by default because of the overhead. It's useful in cases when the partitioning expression's value might change.
145
153
```plpgsql
146
154
create_range_update_trigger(parent REGCLASS)
147
155
```
@@ -281,9 +289,10 @@ When INSERTing new data beyond the partitioning range, use SpawnPartitionsWorker
281
289
```plpgsql
282
290
CREATETABLEIF NOT EXISTS pathman_config (
283
291
partrel REGCLASS NOT NULLPRIMARY KEY,
284
-
attnameTEXTNOT NULL,
292
+
expr TEXTNOT NULL,
285
293
parttype INTEGERNOT NULL,
286
-
range_interval TEXT);
294
+
range_interval TEXT,
295
+
cooked_expr TEXT);
287
296
```
288
297
This table stores a list of partitioned tables.
289
298
@@ -325,7 +334,7 @@ RETURNS TABLE (
325
334
parent REGCLASS,
326
335
partition REGCLASS,
327
336
parttype INT4,
328
-
partattrTEXT,
337
+
expr TEXT,
329
338
range_min TEXT,
330
339
range_max TEXT)
331
340
AS'pg_pathman', 'show_partition_list_internal'
@@ -336,6 +345,23 @@ AS SELECT * FROM show_partition_list();
336
345
```
337
346
This view lists all existing partitions, as well as their parents and range boundaries (NULL for HASH partitions).
0 commit comments