<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Pre-aggregating data in projections</title>
    <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/</link>
    <description>Recent content in Pre-aggregating data in 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/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Data-Analysis: Live aggregate projections</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/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/</guid>
      <description>
        
        
        &lt;p&gt;A live aggregate projection contains columns with values that are aggregated from columns in its anchor table. When you load data into the table, the database aggregates the data before loading it into the live aggregate projection. On subsequent loads—for example, through &lt;a href=&#34;../../../../en/sql-reference/statements/insert/#&#34;&gt;INSERT&lt;/a&gt;or &lt;a href=&#34;../../../../en/sql-reference/statements/copy/#&#34;&gt;COPY&lt;/a&gt;—the database recalculates aggregations with the new data and updates the projection.&lt;/p&gt;


      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Top-k projections</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/top-k-projections/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/top-k-projections/</guid>
      <description>
        
        
        &lt;p&gt;A Top-K query returns the top &lt;em&gt;&lt;code&gt;k&lt;/code&gt;&lt;/em&gt; rows from partitions of selected rows. Top-K projections can significantly improve performance of Top-K queries. For example, you can define a table that stores gas meter readings with three columns: gas meter ID, time of meter reading, and the read value:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE TABLE readings (
    meter_id INT,
    reading_date TIMESTAMP,
    reading_value FLOAT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Given this table, the following Top-K query returns the five most recent meter readings for a given meter:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
SELECT meter_id, reading_date, reading_value FROM readings
    LIMIT 5 OVER (PARTITION BY meter_id ORDER BY reading_date DESC);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To improve the performance of this query, you can create a Top-K projection, which is a special type of live aggregate projection:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE PROJECTION readings_topk (meter_id, recent_date, recent_value)
    AS SELECT meter_id, reading_date, reading_value FROM readings
    LIMIT 5 OVER (PARTITION BY meter_id ORDER BY reading_date DESC);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After you create this Top-K projection and load its data (through &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/projection-functions/start-refresh/#&#34;&gt;START_REFRESH&lt;/a&gt; or &lt;a href=&#34;../../../../en/sql-reference/functions/management-functions/projection-functions/refresh/#&#34;&gt;REFRESH&lt;/a&gt;), the database typically redirects the query to the projection and returns with the pre-aggregated data.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Pre-aggregating UDTF results</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/pre-aggregating-udtf-results/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/pre-aggregating-udtf-results/</guid>
      <description>
        
        
        &lt;p&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/#&#34;&gt;CREATE PROJECTION&lt;/a&gt; can define live aggregate projections that invoke user-defined transform functions (UDTFs). To minimize overhead when you query those projections, OpenText™ Analytics Database processes these functions in the background and stores their results on disk.

&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
Currently, live aggregate projections can only reference UDTFs that are developed in C++.
&lt;/div&gt;&lt;/p&gt;
&lt;h2 id=&#34;defining-projections-with-udtfs&#34;&gt;Defining projections with UDTFs&lt;/h2&gt;
&lt;p&gt;The projection definition characterizes UDTFs in one of two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Identifies the UDTF as a &lt;em&gt;pre-pass UDTF&lt;/em&gt;, which transforms newly loaded data before it is stored in the projection ROS containers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Identifies the UDTF as a &lt;em&gt;batch UDTF&lt;/em&gt;, which aggregates and stores projection data.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The projection definition identifies a UDTF as a pre-pass UDTF or batch UDTF in its &lt;a href=&#34;../../../../en/sql-reference/language-elements/window-clauses/window-partition-clause/&#34;&gt;window partition clause&lt;/a&gt;, through the keywords &lt;code&gt;PREPASS&lt;/code&gt; or &lt;code&gt;BATCH&lt;/code&gt;. A projection can specify one pre-pass or batch UDTF or include both (see &lt;a href=&#34;#UDTFInvocationOptions&#34;&gt;UDTF Specification Options&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;In all cases, the projection is implicitly segmented and ordered on the PARTITION BY columns.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;UDTFInvocationOptions&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;udtf-specification-options&#34;&gt;UDTF specification options&lt;/h2&gt;
&lt;p&gt;Projections can invoke batch and pre-pass UDTFs singly or in combination.&lt;/p&gt;
&lt;h3 id=&#34;single-pre-pass-udtf&#34;&gt;Single pre-pass UDTF&lt;/h3&gt;
&lt;p&gt;The database invokes the pre-pass UDTF when you load data into the projection&#39;s anchor table—for example through COPY or INSERT statements. A pre-pass UDTF transforms the new data and then stores the transformed data in the projection&#39;s ROS containers.&lt;/p&gt;
&lt;p&gt;Use the following syntax:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
CREATE PROJECTION [ IF NOT EXISTS ] [[&lt;span class=&#34;code-variable&#34;&gt;database&lt;/span&gt;.]&lt;span class=&#34;code-variable&#34;&gt;schema.&lt;/span&gt;]&lt;span class=&#34;code-variable&#34;&gt;projection&lt;/span&gt;
[ (
   { &lt;span class=&#34;code-variable&#34;&gt;projection-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/grouped-clause/#&#34;&gt;grouped-clause&lt;/a&gt;&lt;/span&gt;
   [ ENCODING &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/encoding-types/#&#34;&gt;encoding-type&lt;/a&gt;&lt;/span&gt; ]
   [ ACCESSRANK &lt;span class=&#34;code-variable&#34;&gt;integer&lt;/span&gt; ] }[,...]
) ]

AS SELECT { &lt;span class=&#34;code-variable&#34;&gt;table-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;expr-with-table-columns&lt;/span&gt; }[,...], &lt;span class=&#34;code-variable&#34;&gt;prepass-udtf&lt;/span&gt;(&lt;span class=&#34;code-variable&#34;&gt;prepass-args&lt;/span&gt;)
    OVER (PARTITION PREPASS BY &lt;span class=&#34;code-variable&#34;&gt;partition-column-expr&lt;/span&gt;[,...])
    [ AS (&lt;span class=&#34;code-variable&#34;&gt;prepass-output-columns&lt;/span&gt;) ] FROM &lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; [[AS] &lt;span class=&#34;code-variable&#34;&gt;alia&lt;/span&gt;s]
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;single-batch-udtf&#34;&gt;Single batch UDTF&lt;/h3&gt;
&lt;p&gt;When invoked singly, a batch UDTF transforms and aggregates projection data on mergeout, data load, and query operations. The UDTF stores aggregated results in the projection&#39;s ROS containers. Aggregation is cumulative across mergeout and load operations, and is completed (if necessary) on query execution.&lt;/p&gt;
&lt;p&gt;Use the following syntax:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
CREATE PROJECTION [ IF NOT EXISTS ] [[&lt;span class=&#34;code-variable&#34;&gt;database&lt;/span&gt;.]&lt;span class=&#34;code-variable&#34;&gt;schema.&lt;/span&gt;]&lt;span class=&#34;code-variable&#34;&gt;projection&lt;/span&gt;
[ (
   { &lt;span class=&#34;code-variable&#34;&gt;projection-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/grouped-clause/#&#34;&gt;grouped-clause&lt;/a&gt;&lt;/span&gt;
   [ ENCODING &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/encoding-types/#&#34;&gt;encoding-type&lt;/a&gt;&lt;/span&gt; ]
   [ ACCESSRANK &lt;span class=&#34;code-variable&#34;&gt;integer&lt;/span&gt; ]  }[,...]
) ]
AS SELECT { &lt;span class=&#34;code-variable&#34;&gt;table-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;expr-with-table-columns&lt;/span&gt; }[,...], &lt;span class=&#34;code-variable&#34;&gt;batch-udtf&lt;/span&gt;(&lt;span class=&#34;code-variable&#34;&gt;batch-args&lt;/span&gt;)
   OVER (PARTITION BATCH BY &lt;span class=&#34;code-variable&#34;&gt;partition-column-expr&lt;/span&gt;[,...])
   [ AS (&lt;span class=&#34;code-variable&#34;&gt;batch-output-columns&lt;/span&gt;) FROM &lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; [ [AS] &lt;span class=&#34;code-variable&#34;&gt;alias&lt;/span&gt; ]
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;combined-pre-pass-and-batch-udtfs&#34;&gt;Combined pre-pass and batch UDTFs&lt;/h3&gt;
&lt;p&gt;You can define a projection with a subquery that invokes a pre-pass UDTF. The pre-pass UDTF returns transformed data to the outer batch query. The batch UDTF then iteratively aggregates results across mergeout operations. It completes aggregation (if necessary) on query execution.&lt;/p&gt;
&lt;p&gt;Use the following syntax:&lt;br /&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
CREATE PROJECTION [ IF NOT EXISTS ] [[&lt;span class=&#34;code-variable&#34;&gt;database&lt;/span&gt;.]&lt;span class=&#34;code-variable&#34;&gt;schema.&lt;/span&gt;]&lt;span class=&#34;code-variable&#34;&gt;projection&lt;/span&gt;
[ (
   { &lt;span class=&#34;code-variable&#34;&gt;projection-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/grouped-clause/#&#34;&gt;grouped-clause&lt;/a&gt;&lt;/span&gt;
   [ ENCODING &lt;span class=&#34;code-variable&#34;&gt;&lt;a href=&#34;../../../../en/sql-reference/statements/create-statements/create-projection/encoding-types/#&#34;&gt;encoding-type&lt;/a&gt;&lt;/span&gt; ]
   [ ACCESSRANK &lt;span class=&#34;code-variable&#34;&gt;integer&lt;/span&gt; ] }[,...]
) ]
AS SELECT { &lt;span class=&#34;code-variable&#34;&gt;table-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;expr-with-table-columns&lt;/span&gt; }[,...], &lt;span class=&#34;code-variable&#34;&gt;batch-udtf&lt;/span&gt;(&lt;span class=&#34;code-variable&#34;&gt;batch-args&lt;/span&gt;)
   OVER (PARTITION BATCH BY &lt;span class=&#34;code-variable&#34;&gt;partition-column-expr&lt;/span&gt;[,...]) [ AS (&lt;span class=&#34;code-variable&#34;&gt;batch-output-columns&lt;/span&gt;) ] FROM (
      SELECT { &lt;span class=&#34;code-variable&#34;&gt;table-column&lt;/span&gt; | &lt;span class=&#34;code-variable&#34;&gt;expr-with-table-columns&lt;/span&gt; }[,...], &lt;span class=&#34;code-variable&#34;&gt;prepass-udtf&lt;/span&gt; (&lt;span class=&#34;code-variable&#34;&gt;prepass-args&lt;/span&gt;)
      OVER (PARTITION PREPASS BY &lt;span class=&#34;code-variable&#34;&gt;partition-column-expr&lt;/span&gt;[,...]) [ AS (&lt;span class=&#34;code-variable&#34;&gt;prepass-output-columns&lt;/span&gt;) ] FROM &lt;span class=&#34;code-variable&#34;&gt;table&lt;/span&gt; ) &lt;span class=&#34;code-variable&#34;&gt;sq-ref&lt;/span&gt;
&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 outer batch UDTF arguments &lt;em&gt;&lt;code&gt;batch-args&lt;/code&gt;&lt;/em&gt; must exactly match the output columns returned by the pre-pass UDTF, in name and order.
&lt;/div&gt;
&lt;p&gt;&lt;a name=&#34;Examples&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;examples&#34;&gt;Examples&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Single pre-pass UDTF&lt;/strong&gt;&lt;br /&gt;The following example shows how to use the UDTF &lt;code&gt;text_index&lt;/code&gt;, which extracts from a text document strings that occur more than once.&lt;/p&gt;
&lt;p&gt;The following projection specifies to invoke &lt;code&gt;text_index&lt;/code&gt; as a pre-pass UDTF:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; CREATE TABLE documents ( doc_id INT PRIMARY KEY, text VARCHAR(140));

=&amp;gt; CREATE PROJECTION index_proj (doc_id, text)
     AS SELECT doc_id, text_index(doc_id, text)
     OVER (PARTITION PREPASS BY doc_id) FROM documents;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The UDTF is invoked whenever data is loaded into the anchor table &lt;code&gt;documents&lt;/code&gt;. &lt;code&gt;text_index&lt;/code&gt; transforms the newly loaded data, and the database stores the transformed data in the live aggregate projection ROS containers.&lt;/p&gt;
&lt;p&gt;So, if you load the following data into &lt;code&gt;documents&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; INSERT INTO documents VALUES
(100, &amp;#39;A SQL Query walks into a bar. In one corner of the bar are two tables.
 The Query walks up to the tables and asks - Mind if I join you?&amp;#39;);
 OUTPUT
--------
      1
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;text_index&lt;/code&gt; transforms the newly loaded data and stores it in the projection ROS containers. When you query the projection, it returns with the following results:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
doc_id | frequency |     term
-------+-----------+--------------
100    | 2         | bar
100    | 2         | Query
100    | 2         | tables
100    | 2         | the
100    | 2         | walks
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Combined Pre-Pass and Batch UDTFs&lt;/strong&gt;&lt;br /&gt;The following projection specifies pre-pass and batch UDTFs &lt;code&gt;stv_intersect&lt;/code&gt; and &lt;code&gt;aggregate_classified_points&lt;/code&gt;, respectively:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
CREATE TABLE points( point_id INTEGER, point_type VARCHAR(10), coordinates GEOMETRY(100));

CREATE PROJECTION aggregated_proj
   AS SELECT point_type, aggregate_classified_points( sq.point_id, sq.polygon_id)
   OVER (PARTITION BATCH BY point_type) AS some_alias
   FROM
      (SELECT point_type, stv_intersect(
         point_id, coordinates USING PARAMETERS index=&amp;#39;polygons&amp;#39; )
       OVER (PARTITION PREPASS BY point_type) AS (point_id, polygon_id) FROM points) sq;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The pre-pass query UDTF &lt;code&gt;stv_intersect&lt;/code&gt; returns its results (a set of point and matching polygon IDs) to the outer batch query. The outer batch query then invokes the UDTF &lt;code&gt;aggregate_classified_points&lt;/code&gt;. The database aggregates the result set that is returned by &lt;code&gt;aggregate_classified_points&lt;/code&gt; whenever a mergeout operation consolidates projection data. Final aggregation (if necessary) occurs when the projection is queried.&lt;/p&gt;
&lt;p&gt;The batch UDTF arguments must exactly match the output columns returned by the pre-pass UDTF &lt;code&gt;stv_intersect&lt;/code&gt;, in name and order. In this example, the pre-pass subquery explicitly names the pre-pass UDTF output columns &lt;code&gt;point_id&lt;/code&gt; and &lt;code&gt;polygon_id&lt;/code&gt;. Accordingly, the batch UDTF arguments match them in name and order: &lt;code&gt;sq.point_id&lt;/code&gt; and &lt;code&gt;sq.polygon_id&lt;/code&gt;.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Aggregating data through expressions</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/aggregating-data-through-expressions/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/aggregating-data-through-expressions/</guid>
      <description>
        
        
        &lt;p&gt;You can create projections where one or more columns are defined by expressions. An expression can reference one or more anchor table columns. For example, the following table contains two integer columns, &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE values (a INT, b INT);
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can create a projection with an expression that calculates the value of column c as the product of &lt;code&gt;a&lt;/code&gt; and &lt;code&gt;b&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE PROJECTION values_product (a, b, c)
   AS SELECT a, b, a*b FROM values SEGMENTED BY HASH(a) ALL NODES KSAFE;
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When you load data into this projection, OpenText™ Analytics Database resolves the expression &lt;code&gt;a*b&lt;/code&gt; in column c. You can then query the projection instead of the anchor table. The database returns the pre-calculated data and avoids the overhead otherwise incurred by resource-intensive computations.&lt;/p&gt;
&lt;p&gt;Using expressions in projections also lets you sort or segment data on the calculated results of an expression instead of sorting on single column values.

&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;

If a projection with expressions also includes aggregate functions such as &lt;a href=&#34;../../../../en/sql-reference/functions/aggregate-functions/sum-aggregate/&#34;&gt;SUM&lt;/a&gt; or &lt;a href=&#34;../../../../en/sql-reference/functions/aggregate-functions/count-aggregate/&#34;&gt;COUNT&lt;/a&gt;, the database treats it like a &lt;a href=&#34;../../../../en/data-analysis/data-aggregation/pre-aggregating-data-projections/live-aggregate-projections/&#34;&gt;live aggregate projection&lt;/a&gt;.

&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;UDSFSupport&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;support-for-user-defined-scalar-functions&#34;&gt;Support for user-defined scalar functions&lt;/h2&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;
Currently, support for pre-aggregating UDSF results is limited to C++.
&lt;/div&gt;
&lt;p&gt;The database treats user-defined scalar functions (UDSFs) like other expressions. On each load operation, the UDSF is invoked and returns its results. The database stores these results on disk, and returns them when you query the projection directly.&lt;/p&gt;
&lt;p&gt;In the following example, the projection &lt;code&gt;points_p1&lt;/code&gt; specifies the UDSF &lt;code&gt;zorder&lt;/code&gt;, which is invoked whenever data is loaded in the anchor table &lt;code&gt;points&lt;/code&gt;. When data is loaded into the projection, the database invokes this function and stores its results for fast access by future queries.&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE TABLE points(point_id INTEGER, lat NUMERIC(12,9), long NUMERIC(12,9));

=&amp;gt; CREATE PROJECTION points_p1
     AS SELECT point_id, lat, long, zorder(lat, long) zorder FROM points
     ORDER BY zorder(lat, long) SEGMENTED BY hash(point_id) ALL NODES;
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;requirements&#34;&gt;Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Any &lt;code&gt;ORDER BY&lt;/code&gt; expression must be in the &lt;code&gt;SELECT&lt;/code&gt; list.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;All projection columns must be named.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;restrictions&#34;&gt;Restrictions&lt;/h2&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;Unlike live aggregate projections, queries with expressions are not redirected to an equivalent existing projection.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Projection expressions must be immutable—that is, they must always return the same result. For example, a projection cannot include expressions that use &lt;code&gt;TO CHAR&lt;/code&gt; (depends on locale) or &lt;code&gt;RANDOM&lt;/code&gt; (returns different value at each invocation).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Projection expressions cannot include meta-functions such as &lt;code&gt;ADVANCE_EPOCH&lt;/code&gt;, &lt;code&gt;ANALYZE_STATISTICS&lt;/code&gt;, &lt;code&gt;EXPORT_TABLES&lt;/code&gt;, or &lt;code&gt;START_REFRESH&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Data-Analysis: Aggregation information in system tables</title>
      <link>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/aggregation-information-system-tables/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/data-analysis/data-aggregation/pre-aggregating-data-projections/aggregation-information-system-tables/</guid>
      <description>
        
        
        &lt;p&gt;You can query the following system table fields for information about live aggregate projections, Top-K projections, and projections with expressions:

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



&lt;tr&gt; 

&lt;th &gt;
Table&lt;/th&gt; 

&lt;th &gt;
Fields&lt;/th&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/tables/#&#34;&gt;TABLES&lt;/a&gt;&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/tables/#&#34;&gt;TABLE_HAS_AGGREGATE_PROJECTION&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td  rowspan=&#34;3&#34; &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projections/#&#34;&gt;PROJECTIONS&lt;/a&gt;&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projections/#PROJECTIONS_IS_AGGREGATE_TYPE&#34;&gt;AGGREGATE_TYPE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projections/#PROJECTIONS_HAS_EXPRESSIONS&#34;&gt;HAS_EXPRESSIONS&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projections/#PROJECTIONS_IS_AGGREGATE_TYPE&#34;&gt;AGGREGATE_TYPE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td  rowspan=&#34;6&#34; &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#&#34;&gt;PROJECTION_COLUMNS&lt;/a&gt;&lt;/code&gt;&lt;/td&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_COLUMN_EXPRESSION&#34;&gt;COLUMN_EXPRESSION&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_IS_AGGREGATE&#34;&gt;IS_AGGREGATE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_IS_EXPRESSION&#34;&gt;IS_EXPRESSION&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_ORDER_BY_POSITION&#34;&gt;ORDER_BY_POSITION&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_ORDER_BY_TYPE&#34;&gt;ORDER_BY_TYPE&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;tr&gt; 

&lt;td &gt;

&lt;code&gt;&lt;a href=&#34;../../../../en/sql-reference/system-tables/v-catalog-schema/projection-columns/#PROJECTION_COLUMNS_PARTITION_BY_POSITION&#34;&gt;PARTITION_BY_POSITION&lt;/a&gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/p&gt;

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