chrisgarvey
Technical User
Hi forum,
I'm trying to force oracle to use the sort merge using hints.
Can anyone suggest why the below code is working correctly?
Please see the explain plan.
Regards, Chris.
set autotrace on
timing start
select /*+ use_merge(e) */ e.fk, d.fk
FROM girl d, boy e
WHERE e.fk = d.fk;
timing stop
spool off
set termout on
SQL> timing stop
Elapsed: 00:00:00.42
SQL> spool off
not spooling currently
SQL> set termout on
SQL> select * from girl WHERE fk = 1;
PK NAME FK
---------- -------------------- ----------
1 Hayley 1
1 julie 1
1 sian 1
Execution Plan
----------------------------------------------------------
----------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 114 | 3 |
| 1 | TABLE ACCESS FULL| GIRL | 3 | 114 | 3 |
----------------------------------------------------------
Note
-----
- 'PLAN_TABLE' is old version
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
16 consistent gets
0 physical reads
0 redo size
573 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed
I'm trying to force oracle to use the sort merge using hints.
Can anyone suggest why the below code is working correctly?
Please see the explain plan.
Regards, Chris.
set autotrace on
timing start
select /*+ use_merge(e) */ e.fk, d.fk
FROM girl d, boy e
WHERE e.fk = d.fk;
timing stop
spool off
set termout on
SQL> timing stop
Elapsed: 00:00:00.42
SQL> spool off
not spooling currently
SQL> set termout on
SQL> select * from girl WHERE fk = 1;
PK NAME FK
---------- -------------------- ----------
1 Hayley 1
1 julie 1
1 sian 1
Execution Plan
----------------------------------------------------------
----------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost |
----------------------------------------------------------
| 0 | SELECT STATEMENT | | 3 | 114 | 3 |
| 1 | TABLE ACCESS FULL| GIRL | 3 | 114 | 3 |
----------------------------------------------------------
Note
-----
- 'PLAN_TABLE' is old version
Statistics
----------------------------------------------------------
5 recursive calls
0 db block gets
16 consistent gets
0 physical reads
0 redo size
573 bytes sent via SQL*Net to client
381 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
3 rows processed