<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Removing table data</title>
    <link>/en/admin/working-with-native-tables/removing-table-data/</link>
    <description>Recent content in Removing table data on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/working-with-native-tables/removing-table-data/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Data removal operations compared</title>
      <link>/en/admin/working-with-native-tables/removing-table-data/data-removal-operations-compared/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/removing-table-data/data-removal-operations-compared/</guid>
      <description>
        
        
        &lt;p&gt;The following table summarizes differences between various data removal operations.

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
Operations and options&lt;/th&gt; 

&lt;th &gt;
Performance&lt;/th&gt; 

&lt;th &gt;
Auto commits&lt;/th&gt; 

&lt;th &gt;
Saves history&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;DELETE FROM ``table&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


Normal&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;DELETE FROM ``temp-table&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;



&lt;code&gt;DELETE FROM &lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/select/where-clause/#&#34;&gt;where-clause&lt;/a&gt;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


Normal&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;



&lt;code&gt;DELETE FROM &lt;span class=&#34;code-variable&#34;&gt;temp-table&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/select/where-clause/#&#34;&gt;where-clause&lt;/a&gt;&lt;/span&gt;&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


Normal&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;






&lt;pre class=&#34;table-pre&#34;&gt;DELETE FROM &lt;span class=&#34;code-variable&#34;&gt;temp-table&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/select/where-clause/#&#34;&gt;where-clause&lt;/a&gt;&lt;/span&gt; 
ON COMMIT PRESERVE ROWS
&lt;/pre&gt;
&lt;/td&gt; 

&lt;td &gt;


Normal&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;






&lt;pre class=&#34;table-pre&#34;&gt;DELETE FROM &lt;span class=&#34;code-variable&#34;&gt;temp-table&lt;/span&gt; &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/select/where-clause/#&#34;&gt;where-clause&lt;/a&gt;&lt;/span&gt; 
ON COMMIT DELETE ROWS
&lt;/pre&gt;
&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;DROP &lt;/code&gt;&lt;em&gt;&lt;code&gt;table&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;TRUNCATE &lt;/code&gt;&lt;em&gt;&lt;code&gt;table&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;TRUNCATE &lt;/code&gt;&lt;em&gt;&lt;code&gt;temp-table&lt;/code&gt;&lt;/em&gt;&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


&lt;code&gt;SELECT DROP_PARTITIONS (...)&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;


High&lt;/td&gt; 

&lt;td &gt;


Yes&lt;/td&gt; 

&lt;td &gt;


No&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;
&lt;h2 id=&#34;choosing-the-best-operation&#34;&gt;Choosing the best operation&lt;/h2&gt;
&lt;p&gt;The following table can help you decide which operation is best for removing table data:

&lt;table class=&#34;table table-bordered&#34; &gt;



&lt;tr&gt; 

&lt;th &gt;
If you want to...&lt;/th&gt; 

&lt;th &gt;
Use...&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Delete both table data and definitions and start from scratch.&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/drop-statements/drop-table/#&#34;&gt;DROP TABLE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Quickly drop data while preserving table definitions, and reload data.&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/truncate-table/#&#34;&gt;TRUNCATE TABLE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;
Regularly perform bulk delete operations on logical sets of data.&lt;/td&gt; 

&lt;td &gt;

&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;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;


Occasionally perform small deletes with the option to roll back or review history.&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/delete/#&#34;&gt;DELETE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Optimizing DELETE and UPDATE</title>
      <link>/en/admin/working-with-native-tables/removing-table-data/optimizing-delete-and-update/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/removing-table-data/optimizing-delete-and-update/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database is optimized for query-intensive workloads, so DELETE and UPDATE queries might not achieve the same level of performance as other queries. A DELETE and UPDATE operation must update all projections, so the operation can only be as fast as the slowest projection.&lt;/p&gt;
&lt;p&gt;To improve the performance of DELETE and UPDATE queries, consider the following issues:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Query performance after large DELETE operations&lt;/strong&gt;: The implementation of DELETE differs from traditional databases: it does not delete data from disk storage; rather, it marks rows as deleted so they are available for historical queries. Deletion of 10% or more of the total rows in a table can adversely affect queries on that table. In that case, consider &lt;a href=&#34;../../../../en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/&#34;&gt;purging those rows&lt;/a&gt; to improve performance.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Recovery performance&lt;/strong&gt;: Recovery is the action required for a cluster to restore K-safety after a crash. Large numbers of deleted records can degrade the performance of a recovery. To improve recovery performance, &lt;a href=&#34;../../../../en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/&#34;&gt;purge the deleted rows&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Concurrency&lt;/strong&gt;: DELETE and UPDATE take exclusive locks on the table. Only one DELETE or UPDATE transaction on a table can be in progress at a time and only when no load operations are in progress. Delete and update operations on different tables can run concurrently.

&lt;div class=&#34;alert admonition tip&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Tip&lt;/h4&gt;

To optimize large bulk deletion, consider &lt;a href=&#34;../../../../en/admin/partitioning-tables/managing-partitions/dropping-partitions/&#34;&gt;dropping partitions&lt;/a&gt; where possible.

&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;projection-column-requirements-for-optimized-delete&#34;&gt;Projection column requirements for optimized delete&lt;/h2&gt;
&lt;p&gt;A projection is optimized for delete and update operations if it contains all columns required by the query predicate. In general, DML operations are significantly faster when performed on optimized projections than on non-optimized projections.&lt;/p&gt;
&lt;p&gt;For example, consider the following table and projections:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE t (a INTEGER, b INTEGER, c INTEGER);
=&amp;gt; CREATE PROJECTION p1 (a, b, c) AS SELECT * FROM t ORDER BY a;
=&amp;gt; CREATE PROJECTION p2 (a, c) AS SELECT a, c FROM t ORDER BY c, a;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following query, both &lt;code&gt;p1&lt;/code&gt; and &lt;code&gt;p2&lt;/code&gt; are eligible for DELETE and UPDATE optimization because column &lt;code&gt;a&lt;/code&gt; is available:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE from t WHERE a = 1;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In the following example, only projection &lt;code&gt;p1&lt;/code&gt; is eligible for DELETE and UPDATE optimization because the b column is not available in &lt;code&gt;p2&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE from t WHERE b = 1;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;optimized-delete-in-subqueries&#34;&gt;Optimized DELETE in subqueries&lt;/h2&gt;
&lt;p&gt;To be eligible for DELETE optimization, all target table columns referenced in a DELETE or UPDATE statement&#39;s WHERE clause must be in the projection definition.&lt;/p&gt;
&lt;p&gt;For example, the following simple schema has two tables and three projections:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE tb1 (a INT, b INT, c INT, d INT);
=&amp;gt; CREATE TABLE tb2 (g INT, h INT, i INT, j INT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first projection references all columns in &lt;code&gt;tb1&lt;/code&gt; and sorts on column &lt;code&gt;a&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION tb1_p AS SELECT a, b, c, d FROM tb1 ORDER BY a;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The buddy projection references and sorts on column &lt;code&gt;a&lt;/code&gt; in &lt;code&gt;tb1&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION tb1_p_2 AS SELECT a FROM tb1 ORDER BY a;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This projection references all columns in &lt;code&gt;tb2&lt;/code&gt; and sorts on column &lt;code&gt;i&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION tb2_p AS SELECT g, h, i, j FROM tb2 ORDER BY i;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Consider the following DML statement, which references &lt;code&gt;tb1.a&lt;/code&gt; in its &lt;code&gt;WHERE&lt;/code&gt; clause. Since both projections on &lt;code&gt;tb1&lt;/code&gt; contain column &lt;code&gt;a&lt;/code&gt;, both are eligible for the optimized DELETE:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE FROM tb1 WHERE tb1.a IN (SELECT tb2.i FROM tb2);
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;Optimized DELETE operations are not supported under the following conditions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;With replicated projections if subqueries reference the target table. For example, the following syntax is not supported:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE FROM tb1 WHERE tb1.a IN (SELECT e FROM tb2, tb2 WHERE tb2.e = tb1.e);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;With subqueries that do not return multiple rows. For example, the following syntax is not supported:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE FROM tb1 WHERE tb1.a = (SELECT k from tb2);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;projection-sort-order-for-optimizing-delete&#34;&gt;Projection sort order for optimizing DELETE&lt;/h2&gt;
&lt;p&gt;Design your projections so that frequently-used DELETE or UPDATE predicate columns appear in the sort order of all projections for large DELETE and UPDATE operations.&lt;/p&gt;
&lt;p&gt;For example, suppose most of the DELETE queries you perform on a projection look like the following:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; DELETE from t where time_key &amp;lt; &amp;#39;1-1-2007&amp;#39;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To optimize the delete operations, make &lt;code&gt;time_key&lt;/code&gt; appear in the ORDER BY clause of all projections. This schema design results in better performance of the delete operation.&lt;/p&gt;
&lt;p&gt;In addition, add sort columns to the sort order such that each combination of the sort key values uniquely identifies a row or a small set of rows. For more information, see &lt;a href=&#34;../../../../en/admin/configuring-db/creating-db-design/creating-custom-designs/design-fundamentals/choosing-sort-order-best-practices/#&#34;&gt;Choosing sort order: best practices&lt;/a&gt;. To analyze projections for sort order issues, use the &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/projection-functions/evaluate-delete-performance/#&#34;&gt;EVALUATE_DELETE_PERFORMANCE&lt;/a&gt; function.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Purging deleted data</title>
      <link>/en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/</guid>
      <description>
        
        
        &lt;p&gt;Delete operations do not remove rows from physical storage. &lt;a href=&#34;../../../../en/sql-reference/statements/delete/#&#34;&gt;DELETE&lt;/a&gt; marks rows as deleted, as does &lt;a href=&#34;../../../../en/sql-reference/statements/update/#&#34;&gt;UPDATE&lt;/a&gt;, which combines delete and insert operations. In both cases, the database retains discarded rows as historical data, which remains accessible to &lt;a href=&#34;../../../../en/data-analysis/queries/historical-queries/&#34;&gt;historical queries&lt;/a&gt; until it is purged.&lt;/p&gt;
&lt;p&gt;The cost of retaining historical data is twofold:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Disk space is allocated to deleted rows and delete markers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Typical (non-historical) queries must read and skip over deleted data, which can impact performance.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A purge operation permanently removes historical data from physical storage and frees disk space for reuse. Only historical data that precedes the &lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/ancient-history-mark-ahm/&#34; title=&#34;Also known as AHM, the ancient history mark is the oldest epoch whose data is accessible to historical queries.&#34;&gt;Ancient History Mark&lt;/a&gt; (AHM) is eligible to be purged.&lt;/p&gt;
&lt;p&gt;You can purge data in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/setting-purge-policy/&#34;&gt;Set a purge policy&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/admin/working-with-native-tables/removing-table-data/purging-deleted-data/manually-purging-data/&#34;&gt;Manually purge data&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In both cases, the database purges all historical data up to and including the AHM epoch and resets the AHM. See &lt;a href=&#34;../../../../en/admin/failure-recovery/epochs/#&#34;&gt;Epochs&lt;/a&gt; for additional information about how the database uses epochs.

&lt;div class=&#34;admonition caution&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Caution&lt;/h4&gt;

Large delete and purge operations can take a long time to complete, so use them sparingly. If your application requires deleting data on a regular basis, such as by month or year, consider designing tables that take advantage of &lt;a href=&#34;../../../../en/admin/partitioning-tables/&#34;&gt;table partitioning&lt;/a&gt;. If partitioning is not suitable, consider &lt;a href=&#34;../../../../en/admin/working-with-native-tables/rebuilding-tables/&#34;&gt;rebuilding the table&lt;/a&gt;.

&lt;/div&gt;&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Truncating tables</title>
      <link>/en/admin/working-with-native-tables/removing-table-data/truncating-tables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/working-with-native-tables/removing-table-data/truncating-tables/</guid>
      <description>
        
        
        &lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/truncate-table/#&#34;&gt;TRUNCATE TABLE&lt;/a&gt; removes all storage associated with the target table and its projections. The database preserves the table and the projection definitions. If the truncated table has out-of-date projections, those projections are cleared and marked up-to-date when TRUNCATE TABLE returns.&lt;/p&gt;
&lt;p&gt;TRUNCATE TABLE commits the entire transaction after statement execution, even if truncating the table fails. You cannot roll back a TRUNCATE TABLE statement.&lt;/p&gt;
&lt;p&gt;Use TRUNCATE TABLE for testing purposes. You can use it to remove all data from a table and load it with fresh data, without recreating the table and its projections.&lt;/p&gt;
&lt;h2 id=&#34;table-locking&#34;&gt;Table locking&lt;/h2&gt;
&lt;p&gt;TRUNCATE TABLE takes an O (owner) lock on the table until the truncation process completes. The savepoint is then released.&lt;/p&gt;
&lt;p&gt;If the operation cannot obtain an &lt;a href=&#34;../../../../en/admin/db-locks/lock-modes/&#34;&gt;O lock&lt;/a&gt; on the target table, the database tries to close any internal &lt;a href=&#34;../../../../en/admin/managing-db/tuple-mover/&#34;&gt;Tuple Mover&lt;/a&gt; sessions that are running on that table. If successful, the operation can proceed. Explicit Tuple Mover operations that are running in user sessions do not close. If an explicit Tuple Mover operation is running on the table, the operation proceeds only when the operation is complete.&lt;/p&gt;

&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;You cannot truncate an external table.&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; INSERT INTO sample_table (a) VALUES (3);
=&amp;gt; SELECT * FROM sample_table;
a
---
3
(1 row)
=&amp;gt; TRUNCATE TABLE sample_table;
TRUNCATE TABLE
=&amp;gt; SELECT * FROM sample_table;
a
---
(0 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
  </channel>
</rss>
