Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Mon, 26 Sep 2005 @ 17:26:52 GMT


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


Subj:   Re: Redestributing large tables instead of replicating a small table
 
From:   Dieter Noeth

Madhukar Nomula wrote:

  I know this question is asked before, but I did not see the answer.  


  I am trying to join a large 40 million row table with a small 2600 row table. But the explain plan is re-distributing the large table instead replicating the small table on all amps.  


  Here is the query:  


          > SELECT * FROM
          > CONTACT C
          > LEFT JOIN
          > LOCATION D
          > ON
          >   C.LOC_ID = D.LOC_ID;
  The LOC_ID is the NUPI on LOCATION table.  


The optimizer sometimes seems to "forget" about other possibilities if there'a a PI :-)

To make him forget about the PI simply use a calculation on the join column:

     SELECT * FROM
     CONTACT C
     LEFT JOIN
     LOCATION D
     ON
        C.LOC_ID + 0 = D.LOC_ID;

or if it's a char:

     C.LOC_ID || '' = D.LOC_ID;

or for any datatype:

     coalesce(C.LOC_ID, C.LOC_ID) = D.LOC_ID;

This probably changes the explain, then compare explains and performance and please post the results.

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