11g - new: NOT IN has a different behavior with key FOREIGN ACTIVE!

Oracle has changed NOT IN way that works?
The NOT IN operator is supposed to return no rows when there are NULL values, see example below:
Two table c1 (table 1), p2 (table 1 in the parent).

create table c1 (c_col, p_col number);
create table p1 (number p_col);
insert into p1 values ('1');
insert into values p1 (2);
Insert in the values of c1 (100, 1);
Insert in the values of c1 (200, 2);
Insert in the values of c1 (300, null);
Select * C1
If p_col not in (select p_col from p1)
NO RETURNS NO LINE! <-this is the expected behavior

When adding a foreign key, the variations in results:
ALTER TABLE p1
Add CONSTRAINT p_PK PRIMARY KEY (p_col)
ALTER TABLE c1
ADD CONSTRAINT FOREIGN KEY FK1
(p_col) P1 REFERENCES;

THE RESULT OF THE CHANGE:
Select * C1
If p_col not in (select p_col from p1)
RETURNS:
C_COL P_COL
---------------------- ----------------------
300

1 selected lines

WHY?
When the foreign key is disabled, the result does not change back to the old.
-
ALTER table disable forced fk1 c1
Select * C1
If p_col not in (select p_col from p1)
NO RETURNS NO LINE!

Activation of the constraint:
ALTER table ENable constraint fk1 c1
Select * C1
If p_col not in (select p_col from p1)
RETURNS:
C_COL P_COL
---------------------- ----------------------
300

1 selected lines

That's happened?

This is a bug caused by a combination of two elements: [join elimination | http://optimizermagic.blogspot.com/2008/06/why-are-some-of-tables-in-my-query.html] introduced in 10 gr 2 and [Null-aware anti-jointures | http://structureddata.org/2008/05/22/null-aware-anti-join/] introduced in 11 GR 1 material. 11 g CBO to the first query transformations via unnesting of the subquery:

*****************************
Cost-Based Subquery Unnesting
*****************************
SU: Unnesting query blocks in query block SEL$1 (#1) that are valid to unnest.
Subquery Unnesting on query block SEL$1 (#1)SU: Performing unnesting that does not require costing.
SU: Considering subquery unnest on query block SEL$1 (#1).
SU:   Checking validity of unnesting subquery SEL$2 (#2)
SU:   Passed validity checks.
SU: Transform ALL subquery to a single null-aware antijoin.

and then eliminates the join:

*************************
Join Elimination (JE)
*************************
JE:   cfro: C1 objn:61493 col#:2 dfro:P1 dcol#:2
JE:   cfro: C1 objn:61493 col#:2 dfro:P1 dcol#:2
Query block (32724184) before join elimination:
SQL:******* UNPARSED QUERY IS *******
SELECT "C1"."C_COL" "C_COL","C1"."P_COL" "P_COL" FROM "TIM"."P1" "P1","TIM"."C1" "C1" WHERE "C1"."P_COL"="P1"."P_COL"
JE:   eliminate table: P1
Registered qb: SEL$F9980BE6 0x32724184 (JOIN REMOVED FROM QUERY BLOCK SEL$5DA710D3; SEL$5DA710D3; "P1"@"SEL$2")
---------------------
QUERY BLOCK SIGNATURE
---------------------
  signature (): qb_name=SEL$F9980BE6 nbfros=1 flg=0
    fro(0): flg=0 objn=61492 hint_alias="C1"@"SEL$1"

SQL:******* UNPARSED QUERY IS *******
SELECT "C1"."C_COL" "C_COL","C1"."P_COL" "P_COL" FROM "TIM"."C1" "C1" WHERE "C1"."P_COL" IS NULL
Query block SEL$F9980BE6 (#1) simplified

which is obviously false.
With optimizer_features_enable = '10.2.0.4' CBO transforms a NOT EXISTS query, since he cannot transform into normal join:

SELECT "SYS_ALIAS_1"."C_COL" "C_COL","SYS_ALIAS_1"."P_COL" "P_COL" FROM "TIM"."C1" "SYS_ALIAS_1"
WHERE  NOT EXISTS (SELECT 0 FROM "TIM"."P1" "P1" WHERE LNNVL("P1"."P_COL"<>"SYS_ALIAS_1"."P_COL"));

and elimination of join is not even considered.
So as a workaround, you can disable elimination join on either the session or application level via the index OPT_PARAM (although course after approval of Oracle support):

SQL> explain plan for
  2  select /*+ opt_param('_optimizer_join_elimination_enabled' 'false') */ * from c1
  3  where p_col not in (select p_col from p1)
  4  /

Explained

SQL>
SQL> select * from table(dbms_xplan.display)
  2  /

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 1552686931
---------------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |    39 |     5  (20)| 00:00:01 |
|*  1 |  HASH JOIN ANTI SNA|      |     1 |    39 |     5  (20)| 00:00:01 |
|   2 |   TABLE ACCESS FULL| C1   |     3 |    78 |     3   (0)| 00:00:01 |
|   3 |   INDEX FULL SCAN  | P_PK |     2 |    26 |     1   (0)| 00:00:01 |
---------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
   1 - access("P_COL"="P_COL")

BTW, elimination of join has two major bugs: [bad results: https://metalink2.oracle.com/metalink/plsql/f?p=130:14:9360445691478960109:p14_database_id, p14_docid, p14_show_header, p14_show_help, p14_black_frame, p14_font:NOT, 6894671.8, 1, 1, 1, helvetica] with outer joins and [suboptimal plan | https://metalink2.oracle.com/metalink/plsql/f?p=130:15:9360445691478960109:p15_database_id, p15_docid, p15_show_header] [, p15_show_help, p15_black_frame, p15_font:BUG, 7668888, 1, 1, 1, helvetica], making this dangerous service in 10 gr 2 also.

Tags: Database

Similar Questions

  • Different behavior with webworksreadyevent in BONE 10.2.0.341

    I test my app on OS 10.2.0.341 WebWorks and find a problem. When "webworksready" event is triggered, I find that DOM is not yet ready and so document.body returns null. Previously in 10.0 and 10.1, DOM is ready. I use BlackBerry 10 WebWorks SDK 1.0.4.11.

    I was able to workaround it by registering webworksready DOM event is already ready, but I would like to know if this is an unexpected change. Or maybe a new SDK WebWorks can "fix"?

    Happens to your apps, too?

    Thank you.

    This is good feedback, thanks for sharing.

    It is true that DOMReady and webworksready events are independent.  There is no guarantee that we get in front of the other, unless you manage the workflow via the management of events.

  • After my computer will crash does not start has a black screen with message operating system not found. Responsible for recovery disc but wont start.

    not boot Vista after that computer crashed have a black screen with message operating system not found.recovery discs won't load

    Go to your Bios/Setup, or the Boot Menu at startup and change the Boot order to make the DVD/CD drive 1st in the boot order, then reboot with the disk in the drive.

    At the startup/power on you should see at the bottom of the screen either F2 or DELETE, go to Setup/Bios or F12 for the Boot Menu

    Above is the way you normally boot from the Vista recovery disks.

    If you have tried to boot from the recovery without success disks, contact the manufacturer of your computer.

    This isn't their recovery process, Microsoft.

    See you soon,.

    Mick Murphy - Microsoft partner

  • I did the most recent iOS 10 updated, just heard on the news that Yahoo has been hacked.  I changed my Yahoo email but can't find the field to change on my devices.  It is simply not there, what is happening?

    I did the most recent iOS 10 updated, just heard on the news that Yahoo has been hacked.  I changed my password to Yahoo mail but can't find the field to change the password on my devices.  It is simply not there, what is happening?

    For some reason any change automatically if change you it online. Today, I changed my password through my office and I went to change the mail and she had already changed.

    You can try to delete your account your unit off and add it again.

  • According to the set printer wizard, my new printer software has been installed, but the printer will not appear on the section 'printers and faxes '.

    You have a printer again, with installation CD. According to the set printer wizard, my new printer software has been installed, but the printer will not appear on the "printers and faxes" section in Control Panel. Model of printer - Epson XP-200.  Have a Dell, Windows XP.  Help!  Not even sure who to ask...

    What version of XP (Home, Pro, Media Center) and service pack (none, 1, 2, 3)?

    Printers and faxes is totally blank?

    Open a command prompt window (start > run > cmd > OK)
    Type the following in the black command prompt window and press enter
    spooler request SC

    You should see something like this:
    Service_Name: Spooler
    TYPE: 110 WIN32_OWN_PROCESS (interactive)
    STATE: 4 RUNNING
    (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN
    WIN32_EXIT_CODE: 0 (0X0)
    SERVICE_EXIT_CODE: 0 (0X0)
    CHECKPOINT: 0X0
    WAIT_HINT: 0X0

    What is the 'State' displayed for you?

    Open the Services applet (start > run > services.msc > OK) and scroll down to "print spooler".  The status should be started and the Startup Type should be automatic.  What are the parameters of your correspondents?  If your print spooler is stopped, you can try to launch it by clicking on the link, but I suspect that it stops again.  Please report the results of your efforts.

  • new computer only has not a slot CD, how can I reinstall Photoshop?

    My new computer only has not a slot CD, how can I reinstall Photoshop since I have it on a CD format?


    Thank you

    V

    Download Photoshop CS6 for Windows download Creative Suite 6 applications

  • Update trial version, but got and even that will not open because my email associated with the account configuration has changed, so I can't get into it at all. Adobe said that I can't change my email that I have to close my account and start a new. any w

    Update trial version, but got and even that will not open because my email associated with the account configuration has changed, so I can't get into it at all. Adobe said that I can't change my email that I have to close my account and start a new. any way around this? sounds to me ridiculous

    Contacted Adobe Support and they recommended to configure the new Adobe ID?

  • Adobe cloud has 2 different programs of Muse... How do I know that one is new better version?

    So I'm new to Muse, and my Adobe cloud has 2 different programs of Muse... How do I know what is the best new version?

    You must program (Muse CC 2014.2) has a black background when working on it... It looks like other programs such as Photoshop Adobe.

    The other is color of light (Muse CC) very similar to the black color Muse on the functions...

    One of the difference that I see it is that the color of the light Muse has a few widgets in the library, while the black Muse seems to have an empty library

    Then... Why are there 2 different programs of Muse in my cloud of Adobe?

    Hello

    The latest version of Muse is 2014.2, so you need to uninstall another version of Muse manually.

    about library items, you can add items to your library manually, as described in this article

    Adobe help Muse | Organize and reuse design elements using the library panel

    Please let me know if you have any other question.

  • How to locate a new virtual machine on a different hard disk

    VMware Fusion 3.1.1 (282344) Mac OS 10.6.4.

    I have a few virtual machines on my boot drive and am running out of space. I want to create a new Win 7 vm on a drive different but can't seem to figure out how to tell VMware to put there. I know I could create in the normal location on my boot drive and move it, but I didn't Go on the boot drive for this.

    How to create the new virtual machine on the new drive?

    Thx for advice,

    Ken

    As you walk through the Wizard New VM and you arrive at Cap sheet, you have two choices...

    One is to select the Customize settings button and the other is just click the Finish button.  Each choice made appear to save to: dialog box and you can pick any location you want.  Note that you may need to click the down arrow located right of save it under: text box to expand this worksheet to display all the options.  BTW, clicking on this button is the standard behavior of OS X and has nothing to do with the VMware Fusion in itself.

    Post edited by: WoodyZ

  • Problem with the new Notes, do not sync with many testimonies

    I have several iCloud for work and my only personal accounts, since I just have an iPhone, I tried to synchronize all the accounts and their use on the same device.

    I found the following, maybe apple wants to examine, or re-thinking that he...

    HomeMac has my iCloud account staff, main on my iPhone, so the arrival of new tickets I've updated as suggested for the new features, everything went well.

    On my work, that I have a main and other iCloud for test account and so my main account on the desktop, it is not the main on the iPhone, is a secondary antibody and since last September did not want to synchronize the Notes, I couldn't find a reason to today where do more test with multiple accounts. Checking search for differences between accounts on Mac, configuration of web and iPhone iCloud Finally I saw the difference. Main account have the new interface of Notes on the iPhone, iCloud and Mac. Secondary accounts has old interface Notes on Mac / iCloud and iPhone, but always properly synchronized, so that on caos is just my main office account, which has "partially upgraded', when used a desktop Mac, it works under the new Notes interface, iCloud way suite, but at the time I check on a device where is a secondary antibody account he stopped to show me the new data upgrades or data, because it can not "mix" information, is as main account on iPhone has new tickets upgraded, but secondary accounts can not, do not know why, but I guess that has to do with the same question, you can only access info Pages, Numbers and Keynote, on a device, to your iCloud account main If you have a second account, there is no way you can access your information from these applications on the same iPhone / iPad.

    I was happy when Apple decided to make a second account iCloud on our devices and applications (Mail, Notes, calendar, Contacts, etc.) could manage the data separately, which has been a success, al at least for me, but now when Apps allow you to do more, when you try to make / get most of your devices, even once, we face limits that other applications has resolved as Instagram or Twitter where you can switch between the accounts and continue to use the App with a full capacity.

    For me, it is not 'normal' that if I updated a secondary account of new Notes and the iPhone can handle for the main account, this secondary account could not synchronize. I am committed to update on Mac to take advantage of the new features, but if yes, then what is supposed to do with my Notes on the secondary account if they no longer work...

    Please if anyone has an opinion on what might help solve, I will appreciate it.

    Thank you

    To understand, you must also understand how the notes are used to synchronize. Each IMAP account (emails mostly) have an underlying protocol used to perform the synchronization of notes. Icloud account is IMAP, Google is also (or they both have most of the components of the IMAP, but it is more complex then just). Sync IMAP notes would never let features advanced to be synchronized, so had to go with different type of synchronization of server Apple to improve the 'notes' (details - below) but that the clocks single server an account - main. For all those who have upgraded cannot go back and use the IMAP protocol. Therefore, when you add a few accounts to iphone only primary account has one capacity improved and other accounts synchronize using old IMAP.

    The specifications are in this article from apple.

    Before you upgrade your notes - Apple Support

    Upgrading of your notes with iOS 9 and OS X El Capitan - Apple Support

  • ORA-06504 on 11g but not 10g

    I created a database 11g test on vmware server and xp pro. The following code generates an error ORA-06504 on 11g db but not on our database 10g development:

    SQL & gt; Select * from version of v$.

    BANNER
    -----
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    PL/SQL release 11.1.0.6.0 - Production
    CORE 11.1.0.6.0 Production
    AMT for 32-bit Windows: Version 11.1.0.6.0 - Production
    NLSRTL Version 11.1.0.6.0 - Production

    SQL & gt; drop table t is serving;

    Deleted table.

    SQL & gt; create table t (date d, number n, v varchar2 (1));

    Table created.

    SQL & gt; insert into values t (sysdate, 1, ' a');

    1 line of creation.

    SQL & gt; commit;

    Validation complete.

    SQL & gt;
    SQL & gt; declare
    v_curRef sys_refcursor;
    v_recRef t % rowtype;

    procedure prc_base (p_curRef to sys_refcursor) is
    Start
    Open p_curRef SELECT * from t;
    end;
    procedure prc_top (p_curRef to sys_refcursor) is
    Start
    prc_base (p_curRef);
    end;

    Start
    prc_top (v_curRef);
    extract the v_curRef in v_recRef;
    dbms_output.put_line (v_recRef.d);
    dbms_output.put_line (v_recRef.n);
    dbms_output.put_line (v_recRef.v);
    close v_curRef;
    end;
    /
    declare
    *
    ERROR on line 1:
    ORA-06504: PL/SQL: return variables of the game results or the query types do not match
    ORA-06512: at line 16 level

    Any ideas on the reasons of different behavior?

    Thank you.

    This is a bug known, as stated in the Doc 602865.1 ML (ORA-6504 triggered when SYS_REFCURSOR passed to another procedure)

    HTH
    Srini

  • 'New function tab' has stopped working

    The 'new tab' function has stopped working. When I click on the sign '+', nothing opens. When I right click on the Firefox tab in the bottom task bar, I used to get one of the menu options that says 'new tab or new window?', but now I have only 3 options: "Mozilla Firefox; Pin this program to the taskbar; Close this window ". How to re-install the tab' options '?

    Hello

    The reset Firefox feature can solve a lot of problems in restaurant Firefox to its factory default condition while saving your vital information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

    Thank you.

  • After you download Firefox 4, my Google toolbar has disappeared. The new F4 page has no opinion, etc. to tools at the top. WHY I would risk this again by accepting the invitation to download 5?

    After you download Firefox 4, my Google toolbar has disappeared. The new F4 page has no opinion, etc. to tools at the top. WHY I would risk this again by accepting the invitation to download 5?

    Changes in the toolbars:

    I don't like the changes made to the user interface either, rather than to save toolbar space, they would have much more space with 1/10 the functionality. But the important thing is that it's Firefox and you can customize things yourself. Your complaints about the Firefox toolbars are the top 10 items in what follows and they are quickly fixed.

    You can make Firefox 5.0 looks not like Firefox 3.6.19, see numbered 1 to 10 points in the next topic difficulty Firefox 4.0 UI toolbar, problems (Make Firefox 5.0, or 4.0.1 resemble 3.6). If you make changes, you must be aware of what has changed and what it takes to use changed or missing features.

    hostage to the third party toolbar:

    Why you would bind your use of any third-party toolbar browser, which was never really necessary, and even less be hostage to not update to Firefox. Google has had over a year to update their toolbar for Firefox 4 and changes for Firefox 5 could have been tested for several months. Google has waited very long before for finally stating that they would maintain is no longer their toolbar for Firefox, claiming that it was not necessary, and that the items were in Firefox. Also be aware that the features are also in their own browser that also do not need or use the Google toolbar. Not only is Mozilla open source, but all the information is available to anyone - you can even listen online meetings yourself or wait for a printed reviewa.
    There is no change to the user interface of Firefox 4 to 5 and probably even not through Firefox 7

    Life without the Google toolbar:

    You can read this article, on the basis of assessment of own Google features were already in Firefox and expanded from there.

    Kicking a dead horse:

    The Google toolbar is no longer supported by Google in Firefox 5 and more ', you may be able to get what you want from him for a limited time, the instructions to install the Google toolbar have been posted before that Google has actually announced a fall support.

    Please mark solved the problems, so based on the best response to your posted question that solves or helped you to find a solution.

  • Password on notes does not work! Put juice in day to ios9.3 and password to notes, but nothing happened. Notes always open as before. I tried to add new notes too. But nothing happened until now

    Password on notes does not work! Put juice in day to ios9.3 and password to notes, but nothing happened. Notes always open as before. I tried to add new notes too. But nothing has happened so far.

    Same question, the lock in action field icon is absent.

  • What is the "newer" configuration that has both firewire 800 and a dvd?

    I have two old Macs and an iphone 6, so thinking of buying a mac mini. I have an external drive 1 TB, I put in a shell that allows eSata, firewire 800 and 400 connectors, as well as USB. I would also like to whoever owned the DVD player inside.

    What Mac Mini is that the 'new' but still has a firewire 800 connector and a DVD player?

    Also, I have a powerbook g4 15 "and an iMac 350. Is it possible to connect my laptop for a Mac Mini to serve its screen display?

    Thank you

    Charles

    1. models of mid-2010, not counting the one server.

    2. no configuration Virtual Network Computing, which requires an independent monitor.

    (140565)

Maybe you are looking for