<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Defining partitions</title>
    <link>/en/admin/partitioning-tables/defining-partitions/</link>
    <description>Recent content in Defining partitions on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/partitioning-tables/defining-partitions/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Partitioning a new table</title>
      <link>/en/admin/partitioning-tables/defining-partitions/partitioning-new-table/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/partitioning-tables/defining-partitions/partitioning-new-table/</guid>
      <description>
        
        
        &lt;p&gt;Use &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-table/#&#34;&gt;CREATE TABLE&lt;/a&gt; to partition a new table, as specified by the &lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-table/partition-clause/&#34;&gt;PARTITION BY clause&lt;/a&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE TABLE &lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt;... PARTITION BY &lt;span class=&#34;code-variable&#34;&gt;partition-expression&lt;/span&gt; [ GROUP BY &lt;span class=&#34;code-variable&#34;&gt;group-expression&lt;/span&gt; ] [ REORGANIZE ];
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The following statements create the &lt;code&gt;store_orders&lt;/code&gt; table and load data into it. The CREATE TABLE statement includes a simple partition clause that specifies to partition data by year:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE public.store_orders
(
    order_no int,
    order_date timestamp NOT NULL,
    shipper varchar(20),
    ship_date date
)
UNSEGMENTED ALL NODES
PARTITION BY YEAR(order_date);
CREATE TABLE
=&amp;gt; COPY store_orders FROM &amp;#39;/home/dbadmin/export_store_orders_data.txt&amp;#39;;
41834
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As COPY loads the new table data into ROS storage, the Tuple Mover executes the table&#39;s partition clause by dividing orders for each year into separate partitions, and consolidating these partitions in ROS containers.&lt;/p&gt;
&lt;p&gt;In this case, the Tuple Mover creates four partition keys for the loaded data—2017, 2016, 2015, and 2014—and divides the data into separate ROS containers accordingly:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT dump_table_partition_keys(&amp;#39;store_orders&amp;#39;);
... Partition keys on node v_vmart_node0001
  Projection &amp;#39;store_orders_super&amp;#39;
   Storage [ROS container]
     No of partition keys: 1
     Partition keys: 2017
   Storage [ROS container]
     No of partition keys: 1
     Partition keys: 2016
   Storage [ROS container]
     No of partition keys: 1
     Partition keys: 2015
   Storage [ROS container]
     No of partition keys: 1
     Partition keys: 2014

 Partition keys on node v_vmart_node0002
  Projection &amp;#39;store_orders_super&amp;#39;
   Storage [ROS container]
     No of partition keys: 1
     Partition keys: 2017
...

(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;As new data is loaded into &lt;code&gt;store_orders&lt;/code&gt;, the Tuple Mover merges it into the appropriate partitions, creating partition keys as needed for new years.&lt;/p&gt;


      </description>
    </item>
    
    <item>
      <title>Admin: Partitioning existing table data</title>
      <link>/en/admin/partitioning-tables/defining-partitions/partitioning-existing-table-data/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/partitioning-tables/defining-partitions/partitioning-existing-table-data/</guid>
      <description>
        
        
        &lt;p&gt;Use &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#&#34;&gt;ALTER TABLE&lt;/a&gt; to partition or repartition an existing table, as specified by the &lt;code&gt;PARTITION BY&lt;/code&gt; clause:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER TABLE &lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt; PARTITION BY &lt;span class=&#34;code-variable&#34;&gt;partition-expression&lt;/span&gt; [ GROUP BY &lt;span class=&#34;code-variable&#34;&gt;group-expression&lt;/span&gt; ] [ REORGANIZE ];
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For example, you might repartition the &lt;code&gt;store_orders&lt;/code&gt; table, &lt;a href=&#34;../../../../en/admin/partitioning-tables/defining-partitions/partitioning-new-table/&#34;&gt;defined earlier&lt;/a&gt;. The following ALTER TABLE divides all &lt;code&gt;store_orders&lt;/code&gt; data into monthly partitions for each year, each partition key identifying the order date year and month:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE store_orders
     PARTITION BY EXTRACT(YEAR FROM order_date)*100 + EXTRACT(MONTH FROM order_date)
         GROUP BY EXTRACT(YEAR from order_date)*100 + EXTRACT(MONTH FROM order_date);
NOTICE 8364:  The new partitioning scheme will produce partitions in 42 physical storage containers per projection
WARNING 6100:  Using PARTITION expression that returns a Numeric value
HINT:  This PARTITION expression may cause too many data partitions.  Use of an expression that returns a more accurate value, such as a regular VARCHAR or INT, is encouraged
WARNING 4493:  Queries using table &amp;#34;store_orders&amp;#34; may not perform optimally since the data may not be repartitioned in accordance with the new partition expression
HINT:  Use &amp;#34;ALTER TABLE public.store_orders REORGANIZE;&amp;#34; to repartition the data
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After executing this statement, OpenText™ Analytics Database drops existing partition keys. However, the partition clause omits &lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#PartitionBy&#34;&gt;REORGANIZE&lt;/a&gt;, so existing data remains stored according to the previous partition clause. This can put table partitioning in an inconsistent state and adversely affect query performance, &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/drop-partitions/#&#34;&gt;DROP_PARTITIONS&lt;/a&gt;, and node recovery. In this case, you must explicitly request the database to reorganize existing data into new partitions, in one of the following ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Issue ALTER TABLE...REORGANIZE:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER TABLE &lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt; REORGANIZE;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Call the database meta-function &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/partition-table/#&#34;&gt;PARTITION_TABLE&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE store_orders REORGANIZE;
NOTICE 4785:  Started background repartition table task
ALTER TABLE
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;ALTER TABLE...REORGANIZE and PARTITION_TABLE operate identically: both split any ROS containers where partition keys do not conform with the new partition clause. On executing its next mergeout, the Tuple Mover merges partitions into the appropriate ROS containers.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Partition grouping</title>
      <link>/en/admin/partitioning-tables/defining-partitions/partition-grouping/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/partitioning-tables/defining-partitions/partition-grouping/</guid>
      <description>
        
        
        &lt;p&gt;Partition groups consolidate partitions into logical subsets that minimize use of ROS storage. Reducing the number of ROS containers to store partitioned data helps facilitate DML operations such as &lt;code&gt;DELETE&lt;/code&gt; and &lt;code&gt;UPDATE&lt;/code&gt;, and avoid ROS pushback. For example, you can group date partitions by year. By doing so, the Tuple Mover allocates ROS containers for each year group, and merges individual partitions into these ROS containers accordingly.&lt;/p&gt;
&lt;h2 id=&#34;creating-partition-groups&#34;&gt;Creating partition groups&lt;/h2&gt;
&lt;p&gt;You create partition groups by qualifying the &lt;code&gt;PARTITION BY&lt;/code&gt; clause with a &lt;code&gt;GROUP BY&lt;/code&gt; clause:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;ALTER TABLE &lt;span class=&#34;code-variable&#34;&gt;table-name&lt;/span&gt; PARTITION BY &lt;span class=&#34;code-variable&#34;&gt;partition-expression&lt;/span&gt; [ GROUP BY &lt;span class=&#34;code-variable&#34;&gt;group-expression&lt;/span&gt; ]
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;GROUP BY&lt;/code&gt; clause specifies how to consolidate partition keys into groups, where each group is identified by a unique partition group key. For example, the following 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/alter-statements/alter-table/#&#34;&gt;ALTER TABLE&lt;/a&gt;&lt;/code&gt; statement specifies to repartition the &lt;code&gt;store_orders&lt;/code&gt; table (shown in &lt;a href=&#34;../../../../en/admin/partitioning-tables/defining-partitions/partitioning-new-table/#&#34;&gt;Partitioning a new table&lt;/a&gt;) by order dates, grouping partition keys by year. The group expression—&lt;code&gt;DATE_TRUNC(&#39;year&#39;, (order_date)::DATE)&lt;/code&gt;—uses the partition expression &lt;code&gt;order_date::DATE&lt;/code&gt; to generate partition group keys:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER TABLE store_orders
     PARTITION BY order_date::DATE GROUP BY DATE_TRUNC(&amp;#39;year&amp;#39;, (order_date)::DATE) REORGANIZE;
NOTICE 8364:  The new partitioning scheme will produce partitions in 4 physical storage containers per projection
NOTICE 4785:  Started background repartition table task
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In this case, the &lt;code&gt;order_date&lt;/code&gt; column dates span four years. The Tuple Mover creates four partition group keys, and merges &lt;code&gt;store_orders&lt;/code&gt; partitions into group-specific ROS storage containers accordingly:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT DUMP_TABLE_PARTITION_KEYS(&amp;#39;store_orders&amp;#39;);
 ...
 Partition keys on node v_vmart_node0001
  Projection &amp;#39;store_orders_super&amp;#39;
   Storage [ROS container]
     No of partition keys: 173
     Partition keys: 2017-01-02 2017-01-03 2017-01-04 ... 2017-09-25 2017-09-26 2017-09-27
   Storage [ROS container]
     No of partition keys: 212
     Partition keys: 2016-01-01 2016-01-04 2016-01-05 ... 2016-11-23 2016-11-24 2016-11-25
   Storage [ROS container]
     No of partition keys: 213
     Partition keys: 2015-01-01 2015-01-02 2015-01-05 ... 2015-11-23 2015-11-24 2015-11-25
2015-11-26 2015-11-27
   Storage [ROS container]
     No of partition keys: 211
     Partition keys: 2014-01-01 2014-01-02 2014-01-03 ... 2014-11-25 2014-11-26 2014-11-27
  Projection &amp;#39;store_orders_super&amp;#39;
   Storage [ROS container]
     No of partition keys: 173
...
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;admonition caution&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Caution&lt;/h4&gt;

&lt;p&gt;This example demonstrates how partition grouping can facilitate more efficient use of ROS storage. However, grouping all partitions into several large and static ROS containers can adversely affect performance, especially for a table that is subject to frequent DML operations. Frequent load operations in particular can incur considerable merge overhead, which, in turn, reduces performance.&lt;/p&gt;
&lt;p&gt;It is recommended that you use
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/calendar-hierarchy-day/#&#34;&gt;CALENDAR_HIERARCHY_DAY&lt;/a&gt;&lt;/code&gt;, as a partition clause&#39;s group expression. This function automatically groups &lt;code&gt;DATE&lt;/code&gt; partition keys into a dynamic hierarchy of years, months, and days. Doing so helps minimize merge-related issues. For details, see &lt;a href=&#34;../../../../en/admin/partitioning-tables/hierarchical-partitioning/#&#34;&gt;Hierarchical partitioning&lt;/a&gt;.&lt;/p&gt;


&lt;/div&gt;
&lt;h2 id=&#34;managing-partitions-within-groups&#34;&gt;Managing partitions within groups&lt;/h2&gt;
&lt;p&gt;You can use various &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/&#34;&gt;partition management functions&lt;/a&gt;, such as 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/drop-partitions/#&#34;&gt;DROP_PARTITIONS&lt;/a&gt;&lt;/code&gt; or 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/partition-functions/move-partitions-to-table/#&#34;&gt;MOVE_PARTITIONS_TO_TABLE&lt;/a&gt;&lt;/code&gt;, to target a range of order dates within a given partition group, or across multiple partition groups. In the previous example, each group contains partition keys of different dates within a given year. You can use &lt;code&gt;DROP_PARTITIONS&lt;/code&gt; to drop order dates that span two years, 2014 and 2015:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT DROP_PARTITIONS(&amp;#39;store_orders&amp;#39;, &amp;#39;2014-05-30&amp;#39;, &amp;#39;2015-01-15&amp;#39;, &amp;#39;true&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
The drop operation requires the database to &lt;a href=&#34;../../../../en/admin/partitioning-tables/managing-partitions/dropping-partitions/#Splittin&#34;&gt;split the ROS containers that store partition groups&lt;/a&gt; for these two years. To do so, the function&#39;s &lt;code&gt;force_split&lt;/code&gt; parameter must be set to true.
&lt;/div&gt;

      </description>
    </item>
    
  </channel>
</rss>
