SQL> select /*+USE_HASH (lf rf)*/lf.a al,lf.b bl,lf.c cl
2 from test_llf lf,test_rrf rf
3 where lf.a=rf.a(+)
4 union
5 select /*+USE_HASH (lf rf)*/rf.a ar,rf.b br,rf.c cr
6 from test_llf lf,test_rrf rf
7 where rf.a=lf.a(+);
7 rows selected.
Execution Plan
----------------------------------------------------------
0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=11 Card=7 Bytes=36
1 0 SORT (UNIQUE) (Cost=11 Card=7 Bytes=364)
2 1 UNION-ALL
3 2 HASH JOIN (OUTER) (Cost=5 Card=4 Bytes=208)
4 3 TABLE ACCESS (FULL) OF 'TEST_LLF' (TABLE) (Cost=2 Ca
5 3 INDEX (FAST FULL SCAN) OF 'SYS_C005288' (INDEX (UNIQ
6 2 HASH JOIN (OUTER) (Cost=5 Card=3 Bytes=156)
7 6 TABLE ACCESS (FULL) OF 'TEST_RRF' (TABLE) (Cost=2 Ca
8 6 INDEX (FAST FULL SCAN) OF 'SYS_C005287' (INDEX (UNIQ
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
12 consistent gets
0 physical reads
0 redo size
612 bytes sent via SQL*Net to client
512 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
7 rows processed
请问,为什么走hash join时候会发生?
TABLE ACCESS (FULL) OF 'TEST_LLF' (TABLE)
TABLE ACCESS (FULL) OF 'TEST_RRF'
有没有办法不要走TABLE ACCESS ,在两个表都有几百万行的数据情况下,如果改善?