How do I force a hash join [message #143574] |
Thu, 20 October 2005 23:32 |
scottwmackey
Messages: 515 Registered: March 2005
|
Senior Member |
|
|
Does anybody know if and how I can force Oracle to do hash outer join to an inline view? I know that every row in the both tables contained in the view will be hit, so theoretically it should be faster to do a full table scan with hash join. But I can't seem to get Oracle to do it so I can test it. I have tried the USE_HASH hint as shown below. I have tried a FULL hint on the tables in view (as currently commented out so not reflected in the explain plan). Does Oracle know something I don't that it won't let me do this?
SELECT /*+ORDERED FULL(a) PARALLEL(a) FULL(b) PARALLEL(b)USE_HASH(a fim)*/
a.record_seq_num,
a.cusip,
a.primary_exchange,
a.underly_sec_cusip,
a.frst_call_strk_pr,
upper(a.primary_symbol) symbol,
fb_proc.get_date(b.record_dt) record_dt,
'USD' ntv_country_cd,
b.s_p_rating,
b.moody_rating
FROM (SELECT a_in.*,
rank() over(PARTITION BY a_in.cusip ORDER BY a_in.record_seq_num DESC) rnk
FROM fb_prs_desc_a a_in) a
LEFT JOIN fb_prs_desc_b b ON b.record_seq_num = a.record_seq_num
AND b.cusip = a.cusip
LEFT JOIN (SELECT --/*+ FULL(fim_in) FULL(fo)*/
fim_in.*,
fo.expiration_dt,
fo.instr_master_id fo_instr_master_id
FROM fi_instr_master fim_in
LEFT JOIN fi_option fo ON fim_in.instr_master_id = fo.instr_master_id
WHERE rownum > 0
AND fim_in.data_prov_id IN (11, 23)
AND fim_in.definer_id IS NULL) fim ON fim.cusip = a.cusip
AND (fim.fo_instr_master_id IS NULL
OR fim.instr_type_cd = 'RIGHTS'
OR fim.is_actv = 1)
SELECT STATEMENT, GOAL = CHOOSE
NESTED LOOPS OUTER
HASH JOIN OUTER
VIEW Object owner=SMACKEY2
TABLE ACCESS FULL Object owner=SMACKEY2 Object name=FB_PRS_DESC_A
TABLE ACCESS FULL Object owner=SMACKEY2 Object name=FB_PRS_DESC_B
VIEW Object owner=SYS
VIEW Object owner=SMACKEY2
COUNT
FILTER
NESTED LOOPS OUTER
TABLE ACCESS BY INDEX ROWID Object owner=SMACKEY2 Object name=FI_INSTR_MASTER
INDEX SKIP SCAN Object owner=SMACKEY2 Object name=FI_INSTR_MASTER_IX20
INDEX UNIQUE SCAN Object owner=SMACKEY2 Object name=FI_OPTION_PK
|
|
|
Re: How do I force a hash join [message #143683 is a reply to message #143574] |
Fri, 21 October 2005 08:16 |
smartin
Messages: 1803 Registered: March 2005 Location: Jacksonville, Florida
|
Senior Member |
|
|
You mean a hash join instead of nested loops? Typically that is determined by having enough PGA RAM / TEMP space to handle the hash efficiently. hash_area_size, or pga_agg_target.
Also the optimizer parameters play a big role. mode of all rows is more likely to do hash than first rows (choose is being vague, I prefer doing one or the other, and 10g prefers also).
And various optimizer parameters can affect FTS and index access costs to influence the cbo one way or another.
|
|
|
Re: How do I force a hash join [message #143721 is a reply to message #143683] |
Fri, 21 October 2005 11:43 |
scottwmackey
Messages: 515 Registered: March 2005
|
Senior Member |
|
|
smartin,
Thanks much. Yes, I mean hash join instead of nested loop. I am not sure how our various instances are configured but you definitely have provided several avenues for me to explore. It's exactly the info I was looking for. Thanks again.
|
|
|