Example: Statistics Are Not Copied If a Join Operation Is Specified in the Subquery - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

Vantage does not copy statistics if a join operation is specified in the subquery. as the examples in this set demonstrate.

Consider the following view definitions for the examples in this set.

    CREATE VIEW v2 (i, j) AS (
      SELECT SUM(x), y 
      FROM test 
      GROUP BY 2);
    CREATE VIEW v3 (i, j) AS (
      SELECT CASE 
             WHEN z1='abc' 
             THEN 1 
             ELSE 0, a1+1 
      FROM test1);

Example1

In this example, Vantage does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t4 AS (SELECT *
                        FROM test, test1) 
    WITH DATA AND STATISTICS 
    PRIMARY INDEX (z, z1) 
    INDEX (b, b1);

Example2

In this example, Vantage does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t6 (c1, c2, c3, c4) AS (SELECT x1, y1, x-1, y*2
                                         FROM test1, test) 
    WITH DATA AND STATISTICS;

Example3

In this example, Vantage does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t5 AS (SELECT *
                        FROM v2, v3) 
    WITH DATA AND STATISTICS;

Example4

In this example, Vantage does not copy statistics because of the join specification in the subquery.

    CREATE TABLE t5 AS (SELECT *
                        FROM v3, test) 
    WITH DATA AND STATISTICS;