If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How to turn on Merge Join ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-16-09, 03:02
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 94
How to turn on Merge Join ?

Hi All,


How to turn on merge join option in DB2 ? I wanted to know server level and session level option.
Reply With Quote
  #2 (permalink)  
Old 01-16-09, 03:10
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 94
I have gone thorugh the below URL.

DB2 Universal Database


But i couldn't find any option to enable merge join.

Note: There is an option to enable hash join.
Reply With Quote
  #3 (permalink)  
Old 01-16-09, 04:12
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Merge joins (operator MSJOIN) are enabled by default and you can't activate or deactivate them.

Hash joins were introduced in DB2 V7 or V8 (I don't remember) as a new feature so there was an option to explicitly turn them on/off in cause they are desired or cause problems.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 01-16-09, 04:23
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 94
Actually my problem is, i have executed a query in PROD & DEV environment.
There is no difference in the query. but it showed different query plan while executing it in PROD & DEV environment.

PROD:
it uses MERGE JOIN method to join the tables.
DEV:
it uses NESTED LOOP JOIN method to join the tables.

how ?

As you told, if it is enabled by default, how to see that ? my question was is there any variable available to know the status of MERGE JOIN ?
Reply With Quote
  #5 (permalink)  
Old 01-16-09, 06:45
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I said that you can't activate or deactive merge joins. MSJOINs are always activated.

Regarding the differences: do you have the same amount of data in both systems? Do you have the same statistics? Do you use the same hardware (CPU, disk, data distribution)? All this can have an influence on the access plan generated by the optimizer. So I would start with synchronizing the statistics (i.e. copying the stats from the production server to the development system) and then go from there...
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #6 (permalink)  
Old 01-16-09, 07:00
karthi_syb karthi_syb is offline
Registered User
 
Join Date: Jun 2008
Location: India
Posts: 94
I have checked the below in both environment.

1) Statistics
2) Volume of data
3) CPU & Hard Disk speed

There is no difference between them.
Reply With Quote
  #7 (permalink)  
Old 01-16-09, 07:21
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I'm just curious how you verified that there is no difference in statistics between the two environments...
Reply With Quote
  #8 (permalink)  
Old 01-16-09, 10:07
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Does that include cluster ratio? Try reorging the tables on both systems.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #9 (permalink)  
Old 01-16-09, 15:52
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
Quote:
Originally Posted by karthi_syb
PROD: it uses MERGE JOIN method to join the tables.
DEV: it uses NESTED LOOP JOIN method to join the tables.
Two typical reasons for the optimizer to prefer nested loop joins over merge joins:
- the outer table is relatively small
- the cluster ratio of the inner's table join "key" is high
(and the other way around, of course)

So I would indeed expect, as others already stated, that either the outer table's cardinality statistics on your DEV system are a lot smaller than on PROD, or the cluster ratios on at least the inner table differ between PROD and DEV.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On