Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 11 Feb 2005 @ 17:14:02 GMT


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


Subj:   Re: Guidelines for using Distinct vs. group by
 
From:   Dieter Noeth

Brian Jones wrote:

  Are there guidelines on when to use distinct vs. group by? Thank you.  


For columns with equal distribution (for skewed distribution it's hard to say):

- Distinct spools and redistibutes all rows, then eliminates duplicate rows -> efficient if the number of rows per value per AMP is low

- Group by eliminates duplicate rows in the first step locally, then redistributes the result sets and eliminates duplicate rows a second time -> efficient if the nuber of rows per value per AMP is high

- If PI-columns are aggregated ("computed locally" in explain) then Group By is always more efficient.

- And don't forget that a subquery is automatically distinct, but using Group By overrides that.


Dieter



     
  <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