Will primary index be utilised in Teradata if join condition on NON primary index along with primary index columns?
Suppose,
-- Table A
CREATE TABLE Orders (
OrderID INT,
CustomerID INT,
Region VARCHAR(20)
) PRIMARY INDEX (CustomerID);
-- Table B
CREATE TABLE Customers (
CustomerID INT,
Region VARCHAR(20),
Name VARCHAR(50)
) PRIMARY INDEX (CustomerID);
Query:
SELECT *
FROM Orders o
JOIN Customers c
ON o.CustomerID = c.CustomerID -- c.CustomerID is PI
AND o.Region = c.Region -- c.Region is NOT PI
regionis the smaller table, the optimizer probably prepares this table into a spool which is redistributed/duplicated and sorted to match theordersPI, followed by a nerge join. Depending on the actual data there may be a different preparation.