tuning the Skewed joins

Database
Enthusiast

tuning the Skewed joins

Hi,

A query has a join condition and one of the columns in the join is highly skewed with a single value .

Can anybody suggest how can we tune this type of joins. 

Thanks in Advance

Suresh.

3 REPLIES
Junior Contributor

Re: tuning the Skewed joins

Hi Suresh, 

a typical solution would duplicate the query, the first with a condition "WHERE col = skewed_value" and the other "WHERE col <> skewed_value" and UNION ALL both selects.

Of course the optimizer needs statistics on the join columns.

Dieter

Teradata Employee

Re: tuning the Skewed joins

Try first with stats on the column. The extremely skewed values can be dealt with by the optimizer by creating alternate plans. If that does not work, then follow Dieters advice. 

Hint: if you have a significant number of these you are going to love TD14.10! Stay tuned...

Enthusiast

Re: tuning the Skewed joins

Hi Dieter,

Thanks for the reply. I tried with the above union all . the cost is somewhat reduced. but the problem is in the query i have 2 INNER JOINS with this type of skewed column on single side.

INNER JOIN TABLE A

ON A.COL /*999*/  = B.COL   /*UPI*/.

There is only 1 value in B.COL with 999 value and in left COL it is skewed with more values.

Please suggest any solution.

Thanks,

Suresh.