You are on page 1of 20

Join Index & Hash

Index Teradata 14
By: Smarak Das
Employee ID: 391485

Teradata Certified Database Administrator & Solutions Developer


1

Index
----------------------------------------------------------------------------------------------------------------------------------------------- 03

Join Index Introduction

Fully Covering Join Index --------------------------------------------------------------------------------------------------------------------------------------------------- 04

Partially Covering Join Index ------------------------------------------------------------------------------------------------------------------------------------------------- 05

Compression With Join Index ----------------------------------------------------------------------------------------------------------------------------------------------- 07

Rules & Restrictions Of Join Index ----------------------------------------------------------------------------------------------------------------------------------------- 08

Fallback On Join Index ------------------------------------------------------------------------------------------------------------------------------------------------------- 10

Types Of Join Index ----------------------------------------------------------------------------------------------------------------------------------------------------------- 11

Single Table Join Index ------------------------------------------------------------------------------------------------------------------------------------------------------- 12

Multi Table Join Index ------------------------------------------------------------------------------------------------------------------------------------------------------- 13

Aggregate Join Index --------------------------------------------------------------------------------------------------------------------------------------------------------- 14

Sparse Join Index ------------------------------------------------------------------------------------------------------------------------------------------------------------- 15

Hash Index -------------------------------------------------------------------------------------------------------------------------------------------------------------------- 16

Similarity Between Join Index & Hash Index ---------------------------------------------------------------------------------------------------------------------------- 17

Differences Between Join Index & Hash Index -------------------------------------------------------------------------------------------------------------------------- 18

References ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20

Join Index - Introduction


File Structure permitting queries to be resolved using Join Index, rather
than accessing and joining on the underlying tables.

Join Index covers the entire query = Covering Join Index


Join Index covering the entire query via joining with base table = Partially
Covering Join Index

Covering Join Index substitute for the base table(s) and Partially Covering
Join Index part-substitute and part-point to base tables.
3

Fully Covering Join Index


The Join Index covers for all the tables based on which it has been created
in the query. Also, called Index-Only Access.

Query access the Join Index, rather than accessing and possibly, joining
the base tables.

The decision to use Join Index instead of the base tables rests with the
Optimizer only.

Statistics plays an important role for Optimizer to choose the Join Index
rather than the base tables.
4

Partially Covering Join Index


The Join Index contains some columns for the tables which is being
referenced in the query.

The Join Index joins with the base tables for retrieving the additional
columns referenced in the query and not available in the Join Index. Such
operation provides better query optimization than scanning the base tables
for all the columns specified in the query.

Joining with base tables occurs only if ROWID, UPI, USI of the base
tables has been specified as columns of the Join Index.
5

Partially Covering Join Index [Continued]


The process followed for joining with the base table(s):
The Join Index is joined with the other tables to create a temporary table.
The temporary table is redistributed on ROWID, UPI or USI of the base table to perform the join
with the base table.

When ROWID is used, the Join Index is joined with the base tables via ROWID Join.
When UPI or USI is used, the Join Index is joined with the base tables via Merge Join.
The keyword ROWID is a System-Derived Column and can only be used in the Join
Index definition.

Compression With Join Index


When the base tables are compressed with Multi Value Compression (MVC),
the Join Indexs columns are also implicitly compressed.

The following exceptions are applied for Join Index inheriting the
compression of base tables:
The Primary Index columns of Join Index are not compressed.
The Partition Primary Index columns of Join Index are not compressed.
The Aggregate Columns of Join Index are not compressed.
The Columns in the Order By clause of Join Index are not compressed.

Rules & Restrictions Of Join Index

System-derived PARTITION column cannot be used in Join Index.


Total 32 Secondary Index, Join Index and Hash Index are allowed per table.
Block Level Compression is allowed on Join Index.
Only SUM & COUNT aggregate operations are allowed in Join Index.
Unique Primary Index is only allowed in non-compressed single table Join Index.
Unique Secondary Index is not allowed in any Join Index.
Explicit Multi Value Compression (MVC) is not allowed in Join Index.
8

Rules & Restrictions Of Join Index [Continued]

Join Index cannot be directly queried or modified by user.


Join Index cannot be created on another Join Index.
OLAP functions are not allowed in Join Index.
Join Index is allowed on NoPI (No Primary Index) table.
Partition Primary Index is only allowed on Join Index which is not row compressed.
Permanent Journal is not allowed in Join Index.
FastLoad & MultiLoad doesnt support Join Index.
TPUMP, BTEQ, TPT Insert & Stream Operator allows Join Index.
9

Fallback On Join Index


Fallback can be created on Join Index.
If Fallback hasnt been defined on a Join Index and an AMP failure occur,
then the following criteria is critical:
The Join Index cannot be used by Optimizer to solve any queries.
The base tables on which the Join Index is defined cannot be updated. The word

update has been used in generic context to include the delete and update operation
performed by DELETE, MERGE & UPDATE statements.

10

Types Of Join Index


Single Table Join Index Or Multi Table Join Index
Simple Join Index Or Aggregate Join Index
Sparse Join Index

11

Single Table Join Index


Single Table Join Index contains the Data Rows of a single table:
Assume Employee Table has
Employee_No as Primary
Index. The Join Index
Employee_IDX has Primary
Index on Dept_No. If a query
reference Employee Table with
Joining Condition on Dept_No,
no Redistribution or Duplication
is required. Data will be fetched
from the Join Index.

Unique Primary Index is allowed in Single Table Join Index only.


12

Multi Table Join Index


Multi Table Join Index contains the Data Rows of 02 or more tables:
The Join Index
EMP_DEPT_IDX uses
Employee_No as NUPI.
Join Indexes are created so
data doesnt have to move to
satisfy the join. The Join
Index essentially pre-joins
the table and keeps it hidden
for the Parsing Engine to
utilize.
13

Aggregate Join Index


Aggregate Join Index can
use only SUM &
COUNT.
Aggregate Join Index can
be Single Table or Multi
Table.
Count and Sum are
required to be a data type
of FLOAT.

14

Sparse Join Index


A Sparse Join Index is a
Join Index with a
WHERE Clause.
A Sparse Join Index
doesnt take all the rows
in the table, but only a
portion.
Very Effective way to
save space and focus on
the latest data.
15

Hash Index
Structures sharing properties with Single Table Join Index or Secondary Indexes.
Hash Index provides easier creation and deletion feature with few factors
contributing towards to its essence as compared to Single Table Join Index or
Secondary Index.

Hash Index puts in double duty by providing pointers to base tables to facilitate
situations where the index doesnt cover the query fully. These pointers are
transparently added as Primary Index columns by Teradata.

Key difference between Hash Index and Secondary Index is that Hash Index
Partition Key is user selectable.

16

Similarity Between Join Index & Hash Index

Both Join Index & Hash Index are maintained implicitly by Teradata.
Both allows Statistics Collection.
Both can be Hash-Ordered or Value-Ordered.
Both can be Fallback Protected.
Both cannot use PARTITION column.
Both share restrictions with FastLoad, MultiLoad, Archive/Recovery Utility.
Both cannot be directly queries or updated.
17

Difference Between Join Index & Hash Index


Join Index
It allows Single Table as well as
Multi Table.

It inherits Compression from base


tables.

It allows Partitioning.
It is compatible with NoPI Tables.

Hash Index
It allows Single Table only.
It doesnt inherit Compression
from the base tables.

It doesnt allow Partitioning.


It isnt compatible with NoPI
Tables.

18

Difference Between Join Index & Hash Index


Join Index

It is compatible with Triggers.


It allows Aggregate Functions.
It allows NUSI only.
Pointers to base tables explicitly
added via the ROWID keyword.

Hash Index

It isnt compatible with Triggers.


It doesnt allow Aggregate Functions.
It doesnt allow Secondary Index.
Pointers to base tables implicitly
provided via transparently added
primary index columns.
19

References
Teradata Database Design PDF
Teradata Forums
Teradata Magazine Online

For Queries concerning the content, Kindly Email To


Smarak.D@tcs.com [391485]
20

You might also like