Archives of the TeradataForum
Message Posted: Tue, 11 Oct 2005 @ 14:55:06 GMT
Subj: | | Re: Redestributing large tables instead of replicating a small table |
|
From: | | Michael Larkins |
Although doing the aggregation for the following query may at first glance sound like a good idea:
> Basically, I was told that when doing queries such as this :-
>
> sel
> t1.small_table_code
> ,t1.small_table_description
> ,sum(t2.large_table_measure)
>
> from small_table t1
> ,large_table t2
>
> where
> t1.small_table_pi=t2.large_table_column
>
> group by 1,2;
The answer would be wrong. It requests aggregation on only the joined rows. If aggregation is done first, none joined rows are
included in the SUM. Once aggregation is done, all of the detail is gone.
Therefore, there would be no way to subtract out the values for non-matching rows. Even if you could subtract it out, that would be another
step required and probably void any initial improvement in performance. With that said, this technique might provide a basis for discussion if
you are talking about an OUTER JOIN and the aggregation is on a column(s) in the OUTER TABLE.
Regards,
Michael Larkins
Certified Teradata Master
Certified Teradata SQL Instructor
|