All Forums Database
sureshv 5 posts Joined 02/13
01 May 2013
tuning the Skewed joins

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

dnoeth 4628 posts Joined 11/04
02 May 2013

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.


ToddAWalter 316 posts Joined 10/11
02 May 2013

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...

sureshv 5 posts Joined 02/13
20 May 2013

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.


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.





You must sign in to leave a comment.