Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Fri, 13 Oct 2006 @ 15:56:32 GMT


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


Subj:   Re: How to get the REAL explaination for a query with variable
 
From:   Michael Larkins

Silei:

I am more amazed that you got an explain from invalid SQL:

     > Select * from BIG_TABLE, BATCH_TABLE
     > where CRERATED_DATE = max(BATCH_TABLE.BATCH_DATE);

This is an improper use of an aggregate. Plus, it is a cartesian product join (no join condition between Big_table and batch_table - therefore, never a single partition, but instead a full table scan (many times). Look for a product join with a join condition of (1=1).

What happens if you do it correctly:

     Select * from BIG_TABLE
     where CRERATED_DATE = (sel max(BATCH_DATE) from BATCH_TABLE);

Hope this helps,

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