31
31
</listitem>
32
32
</itemizedlist>
33
33
<para>
34
- &productname; supports partitioning via table inheritance. Each
34
+ PostgreSQL supports partitioning via table inheritance. Each
35
35
partition must be created as child table with CHECK CONSTRAINT.
36
36
For example:
37
37
</para>
@@ -80,27 +80,25 @@ WHERE id = 150
80
80
<sect2 id="pg-pathman-installation">
81
81
<title>Installation</title>
82
82
<para>
83
- To installpathman run:
83
+ To installpg_pathman run in psql :
84
84
</para>
85
85
<programlisting>
86
- CREATE SCHEMA pathman;
87
- CREATE EXTENSION pg_pathman SCHEMA pathman;
86
+ CREATE EXTENSION pg_pathman;
88
87
</programlisting>
89
88
<para>
90
- Then modify <literal>shared_preload_libraries</>
91
- parameter in postgresql.conf as
89
+ Then modify shared_preload_libraries parameter in postgres.conf as
92
90
following:
93
91
</para>
94
92
<programlisting>
95
93
shared_preload_libraries = 'pg_pathman'
96
94
</programlisting>
97
95
<para>
98
- It will require to restartof the&productname; instance.
96
+ It will require to restart thePostgreSQL instance.
99
97
</para>
100
98
</sect2>
101
99
<sect2 id="pg-pathman-functions">
102
- <title>FUNCTIONS </title>
103
- <sect3 id="pg-pathman- partitions-creation">
100
+ <title>pg_pathman Functions </title>
101
+ <sect3 id="partitions-creation">
104
102
<title>Partitions Creation</title>
105
103
<programlisting>
106
104
create_hash_partitions(
@@ -112,9 +110,8 @@ create_hash_partitions(
112
110
Performs HASH partitioning for <literal>relation</literal> by
113
111
integer key <literal>attribute</literal>. Creates
114
112
<literal>partitions_count</literal> partitions and trigger on
115
- INSERT. Data doesn't automatically copied from parent table to
116
- partitions. Use <literal>partition_data()</literal> function
117
- (see below) to migrate data.
113
+ INSERT. All the data will be automatically copied from the
114
+ parent to partitions.
118
115
</para>
119
116
<programlisting>
120
117
create_range_partitions(
@@ -123,37 +120,47 @@ create_range_partitions(
123
120
start_value ANYELEMENT,
124
121
interval ANYELEMENT,
125
122
premake INTEGER)
123
+
124
+ create_range_partitions(
125
+ relation TEXT,
126
+ attribute TEXT,
127
+ start_value ANYELEMENT,
128
+ interval INTERVAL,
129
+ premake INTEGER)
126
130
</programlisting>
127
131
<para>
128
132
Performs RANGE partitioning for <literal>relation</literal> by
129
133
partitioning key <literal>attribute</literal>.
130
134
<literal>start_value</literal> argument specifies initial value,
131
135
<literal>interval</literal> sets the range of values in a single
132
136
partition, <literal>premake</literal> is the number of premade
133
- partitions ( theonly one partition will becreated if
134
- <literal>premake</literal> is 0) .
137
+ partitions. All thedata will beautomatically copied from the
138
+ parent to partitions .
135
139
</para>
136
140
<programlisting>
137
- create_range_partitions (
141
+ create_partitions_from_range (
138
142
relation TEXT,
139
143
attribute TEXT,
140
144
start_value ANYELEMENT,
141
- interval INTERVAL,
142
- premake INTEGER)
145
+ end_value ANYELEMENT,
146
+ interval ANYELEMENT)
147
+
148
+ create_partitions_from_range(
149
+ relation TEXT,
150
+ attribute TEXT,
151
+ start_value ANYELEMENT,
152
+ end_value ANYELEMENT,
153
+ interval INTERVAL)
143
154
</programlisting>
144
155
<para>
145
- Same as above but suitable for <literal>DATE</literal> and
146
- <literal>TIMESTAMP</literal> partitioning keys.
156
+ Performs RANGE-partitioning from specified range for
157
+ <literal>relation</literal> by partitioning key
158
+ <literal>attribute</literal>. Data will be copied to partitions
159
+ as well.
147
160
</para>
148
161
</sect3>
149
- <sect3 id="pg-pathman-data-migration">
150
- <title>Data migration</title>
151
- <programlisting>
152
- partition_data(parent text)
153
- </programlisting>
154
- <para>
155
- Copies data from parent table to its partitions.
156
- </para>
162
+ <sect3 id="utilities">
163
+ <title>Utilities</title>
157
164
<programlisting>
158
165
create_hash_update_trigger(parent TEXT)
159
166
</programlisting>
@@ -163,13 +170,13 @@ create_hash_update_trigger(parent TEXT)
163
170
useful in cases when key attribute could be changed.
164
171
</para>
165
172
<programlisting>
166
- create_hash_update_trigger (parent TEXT)
173
+ create_range_update_trigger (parent TEXT)
167
174
</programlisting>
168
175
<para>
169
176
Same as above for RANGE sections.
170
177
</para>
171
178
</sect3>
172
- <sect3 id="pg-pathman- partitions-management">
179
+ <sect3 id="partitions-management">
173
180
<title>Partitions management</title>
174
181
<programlisting>
175
182
split_range_partition(partition TEXT, value ANYELEMENT)
@@ -211,9 +218,9 @@ disable_partitioning(relation TEXT)
211
218
</para>
212
219
</sect3>
213
220
</sect2>
214
- <sect2 id="pg-pathman- examples">
221
+ <sect2 id="examples">
215
222
<title>Examples</title>
216
- <sect3 id="pg-pathman-example- hash">
223
+ <sect3 id="hash">
217
224
<title>HASH</title>
218
225
<para>
219
226
Consider an example of HASH partitioning. First create a table
@@ -226,23 +233,19 @@ CREATE TABLE hash_rel (
226
233
INSERT INTO hash_rel (value) SELECT g FROM generate_series(1, 10000) as g;
227
234
</programlisting>
228
235
<para>
229
- Then run create_hash_partitions() function with appropriate
236
+ If partitions are supposed to have indexes, then they should be
237
+ created for parent table before partitioning. In this case
238
+ pg_pathman will automaticaly create indexes for partitions. Then
239
+ run create_hash_partitions() function with appropriate
230
240
arguments:
231
241
</para>
232
242
<programlisting>
233
243
SELECT create_hash_partitions('hash_rel', 'value', 100);
234
244
</programlisting>
235
245
<para>
236
- This will create new partitions but data will still be in the
237
- parent table. To move data to the corresponding partitions use
238
- partition_data() function:
239
- </para>
240
- <programlisting>
241
- SELECT partition_data('hash_rel');
242
- </programlisting>
243
- <para>
244
- Here is an example of the query with filtering by partitioning
245
- key and its plan:
246
+ This will create new partitions and move the data from parent to
247
+ partitions. Here is an example of the query with filtering by
248
+ partitioning key and its plan:
246
249
</para>
247
250
<programlisting>
248
251
SELECT * FROM hash_rel WHERE value = 1234;
@@ -268,7 +271,7 @@ EXPLAIN SELECT * FROM ONLY hash_rel;
268
271
Seq Scan on hash_rel (cost=0.00..0.00 rows=1 width=8)
269
272
</programlisting>
270
273
</sect3>
271
- <sect3 id="pg-pathman-example- range">
274
+ <sect3 id="range">
272
275
<title>RANGE</title>
273
276
<para>
274
277
Consider an example of RANGE partitioning. Create a table with
@@ -278,26 +281,19 @@ EXPLAIN SELECT * FROM ONLY hash_rel;
278
281
CREATE TABLE range_rel (
279
282
id SERIAL PRIMARY KEY,
280
283
dt TIMESTAMP);
281
- INSERT INTO range_rel (dt) SELECT g FROM generate_series('2010-01-01'::date, '2015 -12-31'::date, '1 day') as g;
284
+ INSERT INTO range_rel (dt) SELECT g FROM generate_series('2010-01-01'::date, '2014 -12-31'::date, '1 day') as g;
282
285
</programlisting>
283
286
<para>
284
287
Run create_range_partitions() function to create partitions so
285
288
that each partition would contain data for one month:
286
289
</para>
287
290
<programlisting>
288
- SELECT create_range_partitions('range_rel', 'dt', '2010-01-01'::date, '1 month'::interval,59 );
291
+ SELECT create_range_partitions('range_rel', 'dt', '2010-01-01'::date, '1 month'::interval,60 );
289
292
</programlisting>
290
293
<para>
291
- It will create 60 partitions (one partition is created
292
- regardless of <literal>premake</literal> parameter). Now move
293
- data from the parent to partitions.
294
- </para>
295
- <programlisting>
296
- SELECT partition_data('range_rel');
297
- </programlisting>
298
- <para>
299
- To merge to adjacent partitions run merge_range_partitions()
300
- function:
294
+ It will create 60 partitions and move the data from parent to
295
+ partitions. To merge to adjacent partitions run
296
+ merge_range_partitions() function:
301
297
</para>
302
298
<programlisting>
303
299
SELECT merge_range_partitions('range_rel_1', 'range_rel_2');
@@ -396,11 +392,14 @@ DELETE FROM pathman_config WHERE relname = 'public.range_rel';
396
392
</programlisting>
397
393
</sect3>
398
394
</sect2>
399
- <sect2 id="pg-pathman- author">
395
+ <sect2 id="author">
400
396
<title>Author</title>
401
397
<para>
402
398
Ildar Musin <email>i.musin@postgrespro.ru</email> Postgres
403
399
Professional Ltd., Russia
404
400
</para>
401
+ <para>
402
+ This module is sponsored by Postgres Professional Ltd., Russia
403
+ </para>
405
404
</sect2>
406
405
</sect1>