Query Plan: Join Index Defined - Teradata Database

Teradata Database Design

Product
Teradata Database
Release Number
15.10
Language
English (United States)
Last Update
2018-10-06
Product Category
Software

Query Plan: Join Index Defined

Now consider the execution plan for this same query when the following join index has been defined:

     CREATE JOIN INDEX OrdCustIdx AS
      SELECT (o_custkey, c_name), (o_status, o_date, o_comment)
      FROM orders, customer
      WHERE o_custkey=c_custkey;

With this join index defined, the execution plan for the query specifies a simple scan of the join index without accessing any of the underlying base tables and without having to join them on the predicate WHERE o_custkey = c_custkey.

In the join index defined for this example, (o_custkey, c_name) is the specified fixed part of the index and (o_status, o_date, o_comment) is the repeated portion. Therefore, assume the following specimen base table entries (where the ? character indicates a null).

 
 

You cannot collect statistics on a complex expression from a base table. If your applications frequently run queries that specify complex expressions in their predicates, you should consider creating a single‑table join index that specifies a matching complex expression in its select list or column list, respectively. When Teradata Database creates the index, it transforms the complex expression into a simple index column on which you can collect statistics.

If the complex expression specified by the index is a term that matches a predicate condition for a query made against the base table the index is defined on, statistics collected on the index expression can be mapped to the base table so the Optimizer can use them to make more accurate single‑table cardinality estimates.