<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Profiling query plans</title>
    <link>/en/admin/profiling-db-performance/profiling-query-plans/</link>
    <description>Recent content in Profiling query plans on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/profiling-db-performance/profiling-query-plans/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Getting query plan status for small queries</title>
      <link>/en/admin/profiling-db-performance/profiling-query-plans/getting-query-plan-status-small-queries/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/profiling-db-performance/profiling-query-plans/getting-query-plan-status-small-queries/</guid>
      <description>
        
        
        &lt;p&gt;Real-time profiling counters, stored in system table 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/execution-engine-profiles/#&#34;&gt;EXECUTION_ENGINE_PROFILES&lt;/a&gt;&lt;/code&gt;, are available for all currently executing statements, including internal operations, such as a &lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/mergeout/&#34; title=&#34;&#34;&gt;mergeout&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Profiling counters are available after query execution completes, if any one of the following conditions is true:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The query was run via the 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/profile/#&#34;&gt;PROFILE&lt;/a&gt;&lt;/code&gt; command&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Systemwide profiling is enabled by meta-function 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/performance-analysis-functions/profiling-functions/enable-profiling/#&#34;&gt;ENABLE_PROFILING&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The query ran more than two seconds.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Profiling counters are saved in system table &lt;code&gt;EXECUTION_ENGINE_PROFILES&lt;/code&gt; until the storage quota is exceeded.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Profile the query to get &lt;code&gt;transaction_id&lt;/code&gt; and &lt;code&gt;statement_id&lt;/code&gt; from from &lt;code&gt;EXECUTION_ENGINE_PROFILES&lt;/code&gt;. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; &lt;span class=&#34;code-input&#34;&gt;PROFILE &lt;/span&gt;SELECT * FROM t1 JOIN t2 ON t1.x = t2.y;
NOTICE 4788:  Statement is being profiled
HINT:  Select * from v_monitor.execution_engine_profiles where &lt;span class=&#34;code-input&#34;&gt;transaction_id=45035996273955065 and statement_id=4;&lt;/span&gt;
NOTICE 3557:  Initiator memory for query: [on pool general: 248544 KB, minimum: 248544 KB]
NOTICE 5077:  Total memory required by query: [248544 KB]
 x | y |   z
---+---+-------
 3 | 3 | three
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Query system table 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/query-plan-profiles/#&#34;&gt;QUERY_PLAN_PROFILES&lt;/a&gt;&lt;/code&gt;.&lt;/p&gt;

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

For best results, sort on columns &lt;code&gt;transaction_id&lt;/code&gt;, &lt;code&gt;statement_id&lt;/code&gt;, &lt;code&gt;path_id&lt;/code&gt;, and &lt;code&gt;path_line_index&lt;/code&gt;.

&lt;/div&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ... FROM query_plan_profiles
     WHERE transaction_id=45035996273955065 and statement_id=4;
     ORDER BY transaction_id, statement_id, path_id, path_line_index;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Getting query plan status for large queries</title>
      <link>/en/admin/profiling-db-performance/profiling-query-plans/getting-query-plan-status-large-queries/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/profiling-db-performance/profiling-query-plans/getting-query-plan-status-large-queries/</guid>
      <description>
        
        
        &lt;p&gt;Real-time profiling is designed to monitor large (long-running) queries. Take the following steps to monitor plans for large queries:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Get the statement and transaction IDs for the query plan you want to profile by querying system table 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/current-session/#&#34;&gt;CURRENT_SESSION&lt;/a&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT transaction_id, statement_id from current_session;
  transaction_id   | statement_id
-------------------+--------------
 &lt;span class=&#34;code-input&#34;&gt;45035996273955001&lt;/span&gt; |            &lt;span class=&#34;code-input&#34;&gt;4&lt;/span&gt;
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the query:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM t1 JOIN t2 ON x=y JOIN ext on y=z;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Query system table 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/query-plan-profiles/#&#34;&gt;QUERY_PLAN_PROFILES&lt;/a&gt;&lt;/code&gt;, and sort on the transaction_id, statement_id, path_id, and path_line_index columns.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ... FROM query_plan_profiles WHERE transaction_id=45035996273955001 and statement_id=4
   ORDER BY transaction_id, statement_id, path_id, path_line_index;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
You can also use the Linux &lt;code&gt;watch&lt;/code&gt; command to monitor long-running queries (see &lt;a href=&#34;../../../../en/admin/profiling-db-performance/real-time-profiling/#&#34;&gt;Real-time profiling&lt;/a&gt;).&lt;/p&gt;
&lt;h2 id=&#34;example&#34;&gt;Example&lt;/h2&gt;
&lt;p&gt;The following series of commands creates a table for a long-running query and then queries system table &lt;code&gt;QUERY_PLAN_PROFILES&lt;/code&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Create table &lt;code&gt;longq&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE longq(x int);
CREATE TABLE
=&amp;gt; COPY longq FROM STDIN;
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself.
&amp;gt;&amp;gt; 1
&amp;gt;&amp;gt; 2
&amp;gt;&amp;gt; 3
&amp;gt;&amp;gt; 4
&amp;gt;&amp;gt; 5
&amp;gt;&amp;gt; 6
&amp;gt;&amp;gt; 7
&amp;gt;&amp;gt; 8
&amp;gt;&amp;gt; 9
&amp;gt;&amp;gt; 10
&amp;gt;&amp;gt; \.
=&amp;gt; INSERT INTO longq SELECT f1.x+f2.x+f3.x+f4.x+f5.x+f6.x+f7.x
      FROM longq f1
      CROSS JOIN longq f2
      CROSS JOIN longq f3
      CROSS JOIN longq f4
      CROSS JOIN longq f5
      CROSS JOIN longq f6
      CROSS JOIN longq f7;
  OUTPUT
----------
 10000000
(1 row)
=&amp;gt; COMMIT;
COMMIT
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Suppress query output on the terminal window by using the vsql &lt;code&gt;\o&lt;/code&gt; command:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \o /home/dbadmin/longQprof
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Query the new table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT * FROM longq;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Get the transaction and statement IDs:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT transaction_id, statement_id from current_session;
  transaction_id   | statement_id
-------------------+--------------
 45035996273955021 |            4
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Turn off the &lt;code&gt;\o&lt;/code&gt; command so OpenText™ Analytics Database continues to save query plan information to the file you specified. Alternatively, leave it on and examine the file after you query system table &lt;code&gt;QUERY_PLAN_PROFILES&lt;/code&gt;.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \o
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Query system table &lt;code&gt;QUERY_PLAN_PROFILES&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT
     transaction_id,
     statement_id,
     path_id,
     path_line_index,
     is_executing,
     running_time,
     path_line
   FROM query_plan_profiles
   WHERE transaction_id=45035996273955021 AND statement_id=4
   ORDER BY transaction_id, statement_id, path_id, path_line_index;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ol&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Improving readability of QUERY_PLAN_PROFILES output</title>
      <link>/en/admin/profiling-db-performance/profiling-query-plans/improving-readability-of-query-plan-profiles-output/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/profiling-db-performance/profiling-query-plans/improving-readability-of-query-plan-profiles-output/</guid>
      <description>
        
        
        &lt;p&gt;Output from the 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/query-plan-profiles/#&#34;&gt;QUERY_PLAN_PROFILES&lt;/a&gt;&lt;/code&gt; table can be very wide because of the &lt;code&gt;path_line&lt;/code&gt; column. To facilitate readability, query &lt;code&gt;QUERY_PLAN_PROFILES&lt;/code&gt; using one or more of the following options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Sort output by &lt;code&gt;transaction_id&lt;/code&gt;, &lt;code&gt;statement_id&lt;/code&gt;, &lt;code&gt;path_id&lt;/code&gt;, and &lt;code&gt;path_line_index&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT ... FROM query_plan_profiles
     WHERE ...
    &lt;span class=&#34;code-input&#34;&gt;ORDER BY transaction_id, statement_id, path_id, path_line_index;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use column aliases to decrease column width:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT statement_id AS &lt;span class=&#34;code-input&#34;&gt;sid&lt;/span&gt;, path_id AS &lt;span class=&#34;code-input&#34;&gt;id&lt;/span&gt;, path_line_index AS &lt;span class=&#34;code-input&#34;&gt;order&lt;/span&gt;,
     is_started AS &lt;span class=&#34;code-input&#34;&gt;start&lt;/span&gt;, is_completed AS &lt;span class=&#34;code-input&#34;&gt;end&lt;/span&gt;, is_executing AS &lt;span class=&#34;code-input&#34;&gt;exe&lt;/span&gt;,
     running_time AS &lt;span class=&#34;code-input&#34;&gt;run&lt;/span&gt;, memory_allocated_bytes AS &lt;span class=&#34;code-input&#34;&gt;mem&lt;/span&gt;,
     read_from_disk_bytes AS &lt;span class=&#34;code-input&#34;&gt;read&lt;/span&gt;, received_bytes AS &lt;span class=&#34;code-input&#34;&gt;rec&lt;/span&gt;,
     sent_bytes AS &lt;span class=&#34;code-input&#34;&gt;sent&lt;/span&gt;, FROM query_plan_profiles
     WHERE transaction_id=45035996273910558 AND statement_id=3
     ORDER BY transaction_id, statement_id, path_id, path_line_index;
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use the vsql &lt;code&gt;\o&lt;/code&gt; command to redirect 
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/explain/#&#34;&gt;EXPLAIN&lt;/a&gt;&lt;/code&gt; output to a file:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; \o /home/dbadmin/long-queries
=&amp;gt; EXPLAIN SELECT * FROM customer_dimension;
=&amp;gt; \o
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Managing query profile data</title>
      <link>/en/admin/profiling-db-performance/profiling-query-plans/managing-query-profile-data/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/profiling-db-performance/profiling-query-plans/managing-query-profile-data/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database retains data for queries until the storage quota for the table is exceeded, when it automatically purges the oldest queries to make room for new ones. You can also clear profiled data by calling one of the following functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/performance-analysis-functions/profiling-functions/clear-profiling/#&#34;&gt;CLEAR_PROFILING&lt;/a&gt; clears profiled data from memory. For example, the following command clears profiling for general query-run information, such as the query strings used and the duration of queries.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CLEAR_PROFILING(&amp;#39;query&amp;#39;);
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/data-collector-functions/clear-data-collector/#&#34;&gt;CLEAR_DATA_COLLECTOR&lt;/a&gt; clears all memory and disk records on the Data Collector tables and functions and resets collection statistics in system table &lt;a href=&#34;../../../../en/sql-reference/system-tables/v-monitor-schema/data-collector/#&#34;&gt;DATA_COLLECTOR&lt;/a&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/data-collector-functions/flush-data-collector/#&#34;&gt;FLUSH_DATA_COLLECTOR&lt;/a&gt; waits until memory logs are moved to disk and then flushes the Data Collector, synchronizing the DataCollector log with the disk storage.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;configuring-data-retention-policies&#34;&gt;Configuring data retention policies&lt;/h2&gt;
&lt;p&gt;The database &lt;a href=&#34;../../../../en/admin/monitoring/data-collector-utility/&#34;&gt;retains the historical data&lt;/a&gt; it gathers as specified by the &lt;a href=&#34;../../../../en/admin/monitoring/data-collector-utility/configuring-data-retention-policies/&#34;&gt;configured&lt;/a&gt; retention policies.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Analyzing suboptimal query plans</title>
      <link>/en/admin/profiling-db-performance/profiling-query-plans/analyzing-suboptimal-query-plans/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/profiling-db-performance/profiling-query-plans/analyzing-suboptimal-query-plans/</guid>
      <description>
        
        
        &lt;p&gt;If profiling uncovers a suboptimal query, invoking one of the following functions might help:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/performance-analysis-functions/workload-management-functions/analyze-workload/#&#34;&gt;ANALYZE_WORKLOAD&lt;/a&gt;&lt;/code&gt; analyzes system information held in system tables and provides tuning recommendations that are based on a combination of statistics, system and &lt;a class=&#34;glosslink&#34; href=&#34;../../../../en/glossary/data-collector/&#34; title=&#34;A utility that collects and retains database monitoring information.&#34;&gt;data collector&lt;/a&gt; events, and database-table-projection design.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;
&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/functions/performance-analysis-functions/statistics-management-functions/analyze-statistics/#&#34;&gt;ANALYZE_STATISTICS&lt;/a&gt;&lt;/code&gt; collects and aggregates data samples and storage information from all nodes that store projections associated with the specified table or column.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can also run your query through the Database Designer. See &lt;a href=&#34;../../../../en/admin/configuring-db/creating-db-design/general-design-settings/#Incremen&#34;&gt;Incremental Design&lt;/a&gt;.&lt;/p&gt;

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