Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Query related to USE_NL hint

1052085Feb 22 2017 — edited Feb 23 2017

Hi,

I have a query in which I want to join 2 tables with nested loop joins.

The query does sometimes takes nested loop join and sometimes doesn't. I'm forcing an hint to make sure it always goes for nested loop.

I was just concerned about the order of the 2 tables in this hint. EMP1 is the smallest table and EMP2 is the largest table. EMP2 has 400 times more records than EMP1. What should be the order of the tables in hint?

/*+ USE_NL(emp1 emp2) */

Note: The actual query is something different. I has just put a below example.

with emp1 as

(

select * from

employee where dept_id = 1

),

emp2 as

(

select * from

employee where dept_id between 2 and 20

)

select /*+ USE_NL(emp1 emp2) */ *

from emp1, emp2

where emp1.role_id = emp2.role_id

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2017
Added on Feb 22 2017
5 comments
4,912 views