Thursday 26 June 2014

Sparse join index

SPARSE join index is being created in Teradata as a result of filtering the rows while joining with the multiple tables.
They are a type of Join Index which contains a WHERE clause that reduces the number of rows which would otherwise be included in the index. 
All types of join indexes, including single table, multitable, simple or aggregate can be sparse. 

Example code:
  1. CREATE JOIN INDEX ind_employee AS
  2. SELECT A.DEPTno , b.sal
  3. FROM
  4. dept A
  5. INNER JOIN
  6. employee B
  7. ON A.deptno=B.dept
  8. WHERE A.deptno=20 --- sparse index
  9. PRIMARY INDEX (sal);


Note:
Join Index never allows a Unique Index to be created.

Explanation:
--> Sal is explicitly mentioned as NUPI
--> A filter clause is applied on Dept.DeptNO = 20, which reduces the number of rows ( an Ideal case of Sparse Index )

No comments:

Post a Comment