Thursday, 11 October 2012

Where and AND clause filter with JOIN

Execution order of WHERE and AND clause

inner join:
1. WHERE clause is applied first and then JOIN is performed
2. Additional AND clause is filtered first and then JOIN is performed

outer join:
1. Additional WHERE clause filtered last after the JOIN is performed.
2. Additional AND clause is applied along with JOIN performed

Table Skewness and PI Distribution Check

locking rows for access
select avg(RC) as avg_rows
,max(RC) as Max_rows
,max(RC)/avg(RC) as Skew_Factor
,count(*) as distict_AMPs
,sum(RC) as RC
from
(select hashamp(hashbucket(hashrow(PI))) ,  cast(count(*) as float) as RC
 from  dbname.tablename
 group by 1
) dt;