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
The <filename>pg_pathman</filename> extension supports
527
-
declarative SQL syntax for partitioning. Using this syntax, you can define partitioning strategy at the time of the table creation, as well as split the already created tables and manage partitions.
syntax for partitioning. Using this syntax, you can
528
+
define partitioning strategy when creating a table, as well
529
+
as partition existing tables and manage table partitions.
528
530
</para>
529
-
<para>When running the <command>CREATE TABLE</command> command, you can use the <literal>PARTITION BY</literal> clause to define tables partitioned by range or hash. </para>
530
-
<para>For example, to create the <literal>abc</literal> table partitioned by range with interval 100, use the following <acronym>SQL</acronym> statement:</para>
531
-
<programlisting>
532
-
CREATE TABLE abc(id SERIAL)
533
-
PARTITION BY RANGE(id) INTERVAL (100);
534
-
</programlisting>
535
-
<para>
536
-
Instead of the <literal>INTERVAL</literal> parameter, you can specify the exact partitions to create, as well as the corresponding tablespaces:
537
-
</para>
538
-
<programlisting>
539
-
CREATE TABLE abc(id SERIAL)
540
-
PARTITION BY RANGE(id)
541
-
(
542
-
PARTITION abc_100 VALUES LESS THAN (100) TABLESPACE ts1,
543
-
PARTITION abc_200 VALUES LESS THAN (200) TABLESPACE ts2
544
-
);
545
-
</programlisting>
546
-
<para>
547
-
When creating a table partitioned by hash, you can either specify the number of partitions to create, or the exact partitions and tablespaces. For example, to create the <literal>abc</literal> table with three partitions, run:
548
-
</para>
549
-
<programlisting>
550
-
CREATE TABLE abc(id serial)
551
-
PARTITION BY HASH (id) PARTITIONS (3);
552
-
</programlisting>
553
-
<para>To define the exact partitions to create, use the following statement:</para>
554
-
<programlisting>
555
-
CREATE TABLE abc(id serial)
556
-
PARTITION BY HASH (id)
557
-
(
558
-
PARTITION abc_first TABLESPACE ts1,
559
-
PARTITION abc_second TABLESPACE ts2
560
-
);
561
-
</programlisting>
562
-
<para>You can also use the <literal>PARTITION BY</literal> clause with the <command>ALTER TABLE</command> <acronym>SQL</acronym> command to partition the already created tables. For example, to split table <literal>abc</literal> to three hash partitions, run:</para>
563
-
<programlisting>
564
-
ALTER TABLE abc PARTITION BY HASH (id) PARTITIONS (3);
565
-
</programlisting>
566
-
<para>When performing range partitioning, specify the lower bound of the first partition and the partitioning interval defining the range of values to include into a single partition:
567
-
<programlisting>
568
-
ALTER TABLE abc PARTITION BY RANGE (id) START FROM (0)
569
-
INTERVAL (2000);
570
-
</programlisting>
571
-
The <literal>START FROM</literal> value must be not greater than the smallest value in the partitioning key column. Otherwise, <filename>pg_pathman</filename> returns the corresponding error.</para>
572
-
<para>If it is critical to avoid downtime, you can use the optional <literal>CONCURRENTLY</literal> parameter when partitioning existing tables. In this case, <filename>pg_pathman</filename> creates empty partitions, and then migrates the data in batches of 1000 rows. For example, to partition a large table with the <literal>INTERVAL</literal> set to 50000, run:
573
-
<programlisting>
574
-
ALTER TABLE abc PARTITION BY RANGE (id) START FROM (0)
575
-
INTERVAL (50000) CONCURRENTLY;
576
-
</programlisting>
577
-
</para>
578
-
<para>Once the table is partitioned, you can use the <command>ALTER TABLE</command> command with partition management clauses provided by <filename>pg_pathman</filename> to add, remove, or modify partitions. For details, see <xref linkend="sql-altertable">.</para>
531
+
<para>
532
+
By default, <filename>pg_pathman</filename> extension is used
533
+
for range and hash partitioning, while list partitioning is disabled.
534
+
To use <productname>&productname;</productname> core functionality
535
+
for partitioning, set the <xref linkend="guc-partition-backend">
536
+
variable to <literal>internal</literal>. In this case, you can
537
+
perform range and list partitioning.
538
+
</para>
539
+
<para>
540
+
You can override the <xref linkend="guc-partition-backend"> setting
541
+
by specifying the <literal>USING <replaceable>partition_backend</replaceable></literal>
542
+
clause for the <xref linkend="sql-createtable"> command.
543
+
</para>
544
+
<para>
545
+
The following partitioning clauses are not supported by
546
+
<filename>pg_pathman</filename>:
547
+
<itemizedlist>
548
+
<listitem>
549
+
<para>
550
+
<command>PARTITION OF</command> clause for <xref linkend="sql-createtable">,
0 commit comments