|
|
Re: Tuning Multiple Not Exists [message #655096 is a reply to message #655094] |
Mon, 22 August 2016 03:57 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
John Watson
Messages: 8964 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
If I give it a no_query_transformation hint, I get the result you want:orclz> select * from table(dbms_xplan.display_cursor(format=>'allstats last'));
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------
SQL_ID 89kpxk66s0nm2, child number 0
-------------------------------------
SELECT /*+ no_query_transformation */ * FROM EMP A WHERE NOT EXISTS
(SELECT 1 FROM EMP_INACTIVE WHERE EMPID = A.ID) AND NOT EXISTS (SELECT
1 FROM EMP_TRANSFERRED WHERE EMPID = A.ID) AND ID IN (105)
Plan hash value: 2374400023
-----------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers |
-----------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 0 |00:00:00.01 | 3 |
|* 1 | FILTER | | 1 | | 0 |00:00:00.01 | 3 |
| 2 | TABLE ACCESS BY INDEX ROWID| EMP | 1 | 1 | 1 |00:00:00.01 | 2 |
|* 3 | INDEX UNIQUE SCAN | MY_EMP_ID_PK | 1 | 1 | 1 |00:00:00.01 | 1 |
|* 4 | INDEX RANGE SCAN | EMP_INACTIVE_INDX01 | 1 | 1 | 1 |00:00:00.01 | 1 |
|* 5 | INDEX RANGE SCAN | EMP_TRANSFERRED_INDX01 | 0 | 1 | 0 |00:00:00.01 | 0 |
-----------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - filter(( IS NULL AND IS NULL))
3 - access("ID"=105)
4 - access("EMPID"=:B1)
5 - access("EMPID"=:B1)
27 rows selected.
orclz> That is a bit drastic though, and not really a good idea. But at least you can see that it is possible, so you should be able to push the CBO towards it. If it really is faster.
[Updated on: Mon, 22 August 2016 07:49] by Moderator Report message to a moderator
|
|
|
|
|
|
|
Re: Tuning Multiple Not Exists [message #655112 is a reply to message #655106] |
Mon, 22 August 2016 07:58 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
John Watson
Messages: 8964 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
Are you saying that my no_query_transformation did not force Oracle to run the query with a filter? That it still re-wrote the query to use joins? I'm surprised.
|
|
|
|
|
|