<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Live aggregate projections</title>
    <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/</link>
    <description>Recent content in Live aggregate projections on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Data-Analysis: Functions supported for live aggregate projections</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/functions-supported-live-aggregate-projections/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/functions-supported-live-aggregate-projections/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database can aggregate results in live aggregate projections from the following aggregate functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/sum-aggregate/#&#34;&gt;SUM&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/max-aggregate/#&#34;&gt;MAX&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/min-aggregate/#&#34;&gt;MIN&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;

&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/aggregate-functions/count-aggregate/#&#34;&gt;COUNT&lt;/a&gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;aggregate-functions-with-distinct&#34;&gt;Aggregate functions with DISTINCT&lt;/h2&gt;
&lt;p&gt;Live aggregate projections can support queries that include aggregate functions qualified with the keyword &lt;code&gt;DISTINCT&lt;/code&gt;. The following requirements apply:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The aggregated expression must evaluate to a non-constant.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The projection&#39;s &lt;code&gt;GROUP BY&lt;/code&gt; clause must specify the aggregated expression.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, the following query uses &lt;code&gt;SUM(DISTINCT)&lt;/code&gt; to calculate the total of all unique salaries in a given region:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SELECT customer_region, SUM(DISTINCT annual_income)::INT
   FROM customer_dimension GROUP BY customer_region;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This query can use the following live aggregate projection, which specifies the aggregated column (&lt;code&gt;annual_income&lt;/code&gt;) in its &lt;code&gt;GROUP BY&lt;/code&gt; clause:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;CREATE PROJECTION public.TotalRegionalIncome
(
 customer_region,
 annual_income,
 Count
)
AS
 SELECT customer_dimension.customer_region,
        customer_dimension.annual_income,
        count(*) AS Count
 FROM public.customer_dimension
 GROUP BY customer_dimension.customer_region,
          customer_dimension.annual_income
;
&lt;/code&gt;&lt;/pre&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;

This projection includes the aggregate function &lt;code&gt;COUNT&lt;/code&gt;, which here serves no logical objective; it is included only because live aggregate projections require at least one aggregate function.

&lt;/div&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Creating live aggregate projections</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/creating-live-aggregate-projections/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/creating-live-aggregate-projections/</guid>
      <description>
        
        
        &lt;p&gt;You define a live aggregate projection with the following syntax:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE PROJECTION &lt;span class=&#34;code-variable&#34;&gt;proj-name&lt;/span&gt; AS
      SELECT &lt;span class=&#34;code-variable&#34;&gt;select-expression&lt;/span&gt; FROM &lt;span class=&#34;code-variable&#34;&gt;table&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;For full syntax options, see &lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-projection/#&#34;&gt;CREATE PROJECTION&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION clicks_agg AS
   SELECT page_id, click_time::DATE click_date, COUNT(*) num_clicks FROM clicks
   GROUP BY page_id, click_time::DATE KSAFE 1;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For an extended discussion, see &lt;a href=&#34;../../../../../en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/live-aggregate-projection-example/#&#34;&gt;Live aggregate projection example&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;p&gt;The following requirements apply to live aggregate projections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;The projection cannot be unsegmented. Unless the CREATE PROJECTION statement or its anchor table DDL &lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-projection/unsegmented-clause/&#34;&gt;specifies otherwise&lt;/a&gt;, all projections are segmented by default.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/select/#&#34;&gt;SELECT&lt;/a&gt; and &lt;a href=&#34;../../../../../en/sql-reference/statements/select/group-by-clause/&#34;&gt;GROUP BY&lt;/a&gt; columns must be in the same order. GROUP BY expressions must be at the beginning of the SELECT list.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&gt;
&lt;p&gt;The following restrictions apply to live aggregate projections:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MERGE operations must be &lt;a href=&#34;../../../../../en/admin/working-with-native-tables/merging-table-data/merge-optimization/&#34;&gt;optimized&lt;/a&gt; if they are performed on target tables that have live aggregate projections.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Live aggregate projections can reference only one table.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Live aggregate projections cannot use row access policies.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The database does not regard live aggregate projections as superprojections, even those that include all table columns.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You cannot &lt;a href=&#34;../../../../../en/admin/working-with-native-tables/managing-table-columns/&#34;&gt;modify the anchor table metadata&lt;/a&gt; of columns that are included in live aggregate projections—for example, a column&#39;s data type or default value. You also cannot &lt;a href=&#34;../../../../../en/admin/working-with-native-tables/altering-table-definitions/dropping-table-columns/&#34;&gt;drop&lt;/a&gt; these columns. To make these changes, first &lt;a href=&#34;../../../../../en/sql-reference/statements/drop-statements/drop-projection/&#34;&gt;drop&lt;/a&gt; all live aggregate and Top-K projections that are associated with the table.&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;

One exception applies: You can set and drop NOT NULL on columns that are included in a live aggregate projection.

&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Live aggregate projection example</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/live-aggregate-projection-example/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/live-aggregate-projection-example/</guid>
      <description>
        
        
        &lt;p&gt;This example shows how you can track user clicks on a given web page using the following &lt;code&gt;clicks&lt;/code&gt; table:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE TABLE clicks(
   user_id INTEGER,
   page_id INTEGER,
   click_time TIMESTAMP NOT NULL);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can aggregate user-specific activity with the following query:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SELECT page_id, click_time::DATE click_date, COUNT(*) num_clicks FROM clicks
   WHERE click_time::DATE = &amp;#39;2015-04-30&amp;#39;
   GROUP BY page_id, click_time::DATE ORDER BY num_clicks DESC;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To facilitate performance of this query, create a live aggregate projection that counts the number of clicks per user:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION clicks_agg AS
   SELECT page_id, click_time::DATE click_date, COUNT(*) num_clicks FROM clicks
   GROUP BY page_id, click_time::DATE KSAFE 1;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you query the &lt;code&gt;clicks&lt;/code&gt; table on user clicks, the database typically directs the query to the live aggregate projection &lt;code&gt;clicks_agg&lt;/code&gt;. As additional data is loaded into &lt;code&gt;clicks&lt;/code&gt;, the database pre-aggregates the new data and updates &lt;code&gt;clicks_agg&lt;/code&gt;, so queries always return with the latest data.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT page_id, click_time::DATE click_date, COUNT(*) num_clicks FROM clicks
    WHERE click_time::DATE = &amp;#39;2015-04-30&amp;#39; GROUP BY page_id, click_time::DATE
    ORDER BY num_clicks DESC;
 page_id | click_date | num_clicks
---------+------------+------------
    2002 | 2015-04-30 |         10
    3003 | 2015-04-30 |          3
    2003 | 2015-04-30 |          1
    2035 | 2015-04-30 |          1
   12034 | 2015-04-30 |          1
(5 rows)
&lt;/code&gt;&lt;/pre&gt;
      </description>
    </item>
    
  </channel>
</rss>
