Hi, I have the following question.
Assume that I have a table T, with:
- columns (A, B), together as PRIMARY UNIQUE INDEX
- a lot of other columns, e.g. C1..C100.
Table T contains millions of rows, and for each of them, the column A is always a constant, e.g.:
A B C1 C2 ...
1 100 200 300
1 101 300 302
1 102 305 99
In a select query, I join table T with another table X on column B:
sel * from T INNER JOIN X ON T.B = X.B
WHERE C1 = ... AND C2 = ... AND ....
Someone told me that it would be drastically more efficient if I rewrite the query like this:
WHERE A = 1 AND C1 = ... AND C2 = ... AND ....
He said that, even though the condition A=1 is trivially always true, this is totally faster for the Teradata engine because in this way we are accessing table T by its full primary key.
The first question is: is that true? Is the query really faster, even though I NEVER need to use the column A anywhere else (it does not provide any useful data being it a constant)?
The second question is: same as first question, in the case where A is the only PRIMARY INDEX and B is a normal column (and yes, same queries as before, with the join condition on B).
Thank you very much.