Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Tue, 11 Oct 2005 @ 14:55:06 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


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



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023