Home » RDBMS Server » Performance Tuning » "NOT IN" REPLACE WITH "MINUS" (Oracle 10gR2)
"NOT IN" REPLACE WITH "MINUS" [message #523041] Thu, 15 September 2011 06:28 Go to next message
thinknightgmailcom
Messages: 1
Registered: September 2011
Junior Member
I have 2 questions for this SQL Statement for tuning?

select * from a where id not in (select a_id from b)
1- How do i change this query with A MINUS OPERATOR

2- Shall i use a Hint for this query?

Explain plan is:

Execution Plan

--------------------------------------------------------------------------------
Plan hash value: 31652112322


--------------------------------------------------------------------------------
-

| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time
|


--------------------------------------------------------------------------------
-

| 0 | SELECT STATEMENT | | 299 | 21528 | 9 (12)| 00:00:01
|

|* 1 | HASH JOIN RIGHT ANTI| | 299 | 21528 | 9 (12)| 00:00:01
|

|* 2 | TABLE ACCESS FULL | b | 1 | 23 | 4 (0)| 00:00:01
|

| 3 | TABLE ACCESS FULL | a | 300 | 14700 | 4 (0)| 00:00:01
|


--------------------------------------------------------------------------------
-

How do i optimize it best?







Re: "NOT IN" REPLACE WITH "MINUS" [message #523051 is a reply to message #523041] Thu, 15 September 2011 07:04 Go to previous message
Michel Cadot
Messages: 68641
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
1.
Generate execution for both and compare them.
The answer depends on your data.

2.
You must NOT use hint for such queries.

Regards
Michel
Previous Topic: Perfomance problem with select distinct from cartesian join with OR-ed filter
Next Topic: select partition issue
Goto Forum:
  


Current Time: Thu Apr 18 08:26:33 CDT 2024