• oracle 11g not in 与not exists 那个高效?


    网络上很多谣言是后面跟小表用not in,后面跟大表用not exists,难道真的是这样子的嘛?

    情况下面测试:

    1、先用小表测试(1000条记录和一张8万条记录的表):

    SQL> create table not_in_s as select * from dba_objects where object_id <= 10000;

    Table created.

    Elapsed: 00:00:00.17

    SQL> create table not_exists_s as select * from dba_objects where object_id <= 10000;

    Table created.

    查看执行计划:

    小表not in

    set autotrace traceonly explain

    SQL> select * from dba_objects where object_id 

    not in (select object_id from not_exists_s);
    Elapsed: 00:00:00.06

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 566308792

    -----------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    -----------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 87028 | 18M| 337 (1)| 00:00:05 |
    |* 1 | HASH JOIN RIGHT ANTI NA | | 87028 | 18M| 337 (1)| 00:00:05 |
    | 2 | TABLE ACCESS FULL | NOT_EXISTS_S | 11495 | 145K| 36 (0)| 00:00:01 |
    | 3 | VIEW | DBA_OBJECTS | 87036 | 17M| 301 (1)| 00:00:04 |
    | 4 | UNION-ALL | | | | | |
    |* 5 | TABLE ACCESS BY INDEX ROWID| SUM$ | 1 | 9 | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | I_SUM$_1 | 1 | | 0 (0)| 00:00:01 |
    | 7 | TABLE ACCESS BY INDEX ROWID| OBJ$ | 1 | 30 | 3 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_OBJ1 | 1 | | 2 (0)| 00:00:01 |
    |* 9 | FILTER | | | | | |
    |* 10 | HASH JOIN | | 87035 | 10M| 299 (2)| 00:00:04 |
    | 11 | TABLE ACCESS CLUSTER | USER$ | 92 | 1564 | 3 (0)| 00:00:01 |
    | 12 | INDEX FULL SCAN | I_USER# | 1 | | 1 (0)| 00:00:01 |
    |* 13 | HASH JOIN | | 87035 | 9009K| 296 (2)| 00:00:04 |
    | 14 | INDEX FULL SCAN | I_USER2 | 92 | 2024 | 1 (0)| 00:00:01 |
    |* 15 | TABLE ACCESS FULL | OBJ$ | 87035 | 7139K| 294 (1)| 00:00:04 |
    | 16 | NESTED LOOPS | | 1 | 29 | 2 (0)| 00:00:01 |
    |* 17 | INDEX SKIP SCAN | I_USER2 | 1 | 20 | 1 (0)| 00:00:01 |
    |* 18 | INDEX RANGE SCAN | I_OBJ4 | 1 | 9 | 1 (0)| 00:00:01 |
    | 19 | NESTED LOOPS | | 1 | 105 | 2 (0)| 00:00:01 |
    | 20 | TABLE ACCESS FULL | LINK$ | 1 | 88 | 2 (0)| 00:00:01 |
    | 21 | TABLE ACCESS CLUSTER | USER$ | 1 | 17 | 0 (0)| 00:00:01 |
    |* 22 | INDEX UNIQUE SCAN | I_USER# | 1 | | 0 (0)| 00:00:01 |
    -----------------------------------------------------------------------------------------------

    Predicate Information (identified by operation id):
    ---------------------------------------------------

    1 - access("OBJECT_ID"="OBJECT_ID")
    5 - filter(BITAND("S"."XPFLAGS",8388608)=8388608)
    6 - access("S"."OBJ#"=:B1)
    8 - access("EO"."OBJ#"=:B1)
    9 - filter("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8
    AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND
    "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88 OR
    BITAND("U"."SPARE1",16)=0 OR ("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR
    "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12
    OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND
    (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2 OR
    "U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))
    OR EXISTS (SELECT 0 FROM SYS."USER$" "U2",SYS."OBJ$" "O2" WHERE
    "O2"."OWNER#"="U2"."USER#" AND "O2"."TYPE#"=88 AND "O2"."DATAOBJ#"=:B1 AND
    "U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))
    )))
    10 - access("O"."SPARE3"="U"."USER#")
    13 - access("O"."OWNER#"="U"."USER#")
    15 - filter("O"."TYPE#"<>10 AND "O"."NAME"<>'_NEXT_OBJECT' AND
    "O"."NAME"<>'_default_auditing_options_' AND "O"."LINKNAME" IS NULL AND
    BITAND("O"."FLAGS",128)=0)
    17 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current
    _edition_id')))
    filter("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current
    _edition_id')))
    18 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
    22 - access("L"."OWNER#"="U"."USER#")

    Note
    -----
    - dynamic sampling used for this statement (level=2)

    小表 not exists:

    SQL> select * from dba_objects where not exists
    (select object_id from not_in_s where not_in_s.object_id = dba_objects.object_id);
    Elapsed: 00:00:00.04

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4002778081

    ----------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    ----------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 87027 | 18M| 337 (1)| 00:00:05 |
    |* 1 | HASH JOIN RIGHT ANTI | | 87027 | 18M| 337 (1)| 00:00:05 |
    | 2 | TABLE ACCESS FULL | NOT_IN_S | 9749 | 123K| 36 (0)| 00:00:01 |
    | 3 | VIEW | DBA_OBJECTS | 87036 | 17M| 301 (1)| 00:00:04 |
    | 4 | UNION-ALL | | | | | |
    |* 5 | TABLE ACCESS BY INDEX ROWID| SUM$ | 1 | 9 | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | I_SUM$_1 | 1 | | 0 (0)| 00:00:01 |
    | 7 | TABLE ACCESS BY INDEX ROWID| OBJ$ | 1 | 30 | 3 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_OBJ1 | 1 | | 2 (0)| 00:00:01 |
    |* 9 | FILTER | | | | | |
    |* 10 | HASH JOIN | | 87035 | 10M| 299 (2)| 00:00:04 |
    | 11 | TABLE ACCESS CLUSTER | USER$ | 92 | 1564 | 3 (0)| 00:00:01 |
    | 12 | INDEX FULL SCAN | I_USER# | 1 | | 1 (0)| 00:00:01 |
    |* 13 | HASH JOIN | | 87035 | 9009K| 296 (2)| 00:00:04 |
    | 14 | INDEX FULL SCAN | I_USER2 | 92 | 2024 | 1 (0)| 00:00:01 |
    |* 15 | TABLE ACCESS FULL | OBJ$ | 87035 | 7139K| 294 (1)| 00:00:04 |
    | 16 | NESTED LOOPS | | 1 | 29 | 2 (0)| 00:00:01 |
    |* 17 | INDEX SKIP SCAN | I_USER2 | 1 | 20 | 1 (0)| 00:00:01 |
    |* 18 | INDEX RANGE SCAN | I_OBJ4 | 1 | 9 | 1 (0)| 00:00:01 |
    | 19 | NESTED LOOPS | | 1 | 105 | 2 (0)| 00:00:01 |
    | 20 | TABLE ACCESS FULL | LINK$ | 1 | 88 | 2 (0)| 00:00:01 |
    | 21 | TABLE ACCESS CLUSTER | USER$ | 1 | 17 | 0 (0)| 00:00:01 |
    |* 22 | INDEX UNIQUE SCAN | I_USER# | 1 | | 0 (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------

    Predicate Information (identified by operation id):
    ---------------------------------------------------

    1 - access("NOT_IN_S"."OBJECT_ID"="DBA_OBJECTS"."OBJECT_ID")
    5 - filter(BITAND("S"."XPFLAGS",8388608)=8388608)
    6 - access("S"."OBJ#"=:B1)
    8 - access("EO"."OBJ#"=:B1)
    9 - filter("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8
    AND "O"."TYPE#"<>9 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND
    "O"."TYPE#"<>14 AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88 OR
    BITAND("U"."SPARE1",16)=0 OR ("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR
    "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12
    OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND
    (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE' AND "U"."TYPE#"<>2 OR
    "U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id'))
    OR EXISTS (SELECT 0 FROM SYS."USER$" "U2",SYS."OBJ$" "O2" WHERE
    "O2"."OWNER#"="U2"."USER#" AND "O2"."TYPE#"=88 AND "O2"."DATAOBJ#"=:B1 AND
    "U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')
    ))))
    10 - access("O"."SPARE3"="U"."USER#")
    13 - access("O"."OWNER#"="U"."USER#")
    15 - filter("O"."TYPE#"<>10 AND "O"."NAME"<>'_NEXT_OBJECT' AND
    "O"."NAME"<>'_default_auditing_options_' AND "O"."LINKNAME" IS NULL AND
    BITAND("O"."FLAGS",128)=0)
    17 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','curren
    t_edition_id')))
    filter("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','curren
    t_edition_id')))
    18 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
    22 - access("L"."OWNER#"="U"."USER#")

    Note
    -----
    - dynamic sampling used for this statement (level=2)

    1000行记录的小表用not in,not exists 消耗的成本都是337。

    2、先用大表测试(5万条记录和一张8万条记录的表):

    SQL> create table not_in_b as select * from dba_objects where object_id <= 50000;
    create table not_exists_b as select * from dba_objects where object_id <= 50000;
    Table created.

    Elapsed: 00:00:00.55
    SQL>

    Table created.

    Elapsed: 00:00:00.50

    大表not in:

    SQL> select * from dba_objects where object_id
     not in (select object_id from not_exists_b);
    Elapsed: 00:00:00.07

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3301458141

    -------------------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    -------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 87034 | 18M| | 1445 (1)| 00:00:18 |
    |* 1 | HASH JOIN RIGHT ANTI NA | | 87034 | 18M| 1032K| 1445 (1)| 00:00:18 |
    | 2 | TABLE ACCESS FULL | NOT_EXISTS_B | 42206 | 535K| | 192 (0)| 00:00:03 |
    | 3 | VIEW | DBA_OBJECTS | 87036 | 17M| | 301 (1)| 00:00:04 |
    | 4 | UNION-ALL | | | | | | |
    |* 5 | TABLE ACCESS BY INDEX ROWID| SUM$ | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | I_SUM$_1 | 1 | | | 0 (0)| 00:00:01 |
    | 7 | TABLE ACCESS BY INDEX ROWID| OBJ$ | 1 | 30 | | 3 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 2 (0)| 00:00:01 |
    |* 9 | FILTER | | | | | | |
    |* 10 | HASH JOIN | | 87035 | 10M| | 299 (2)| 00:00:04 |
    | 11 | TABLE ACCESS CLUSTER | USER$ | 92 | 1564 | | 3 (0)| 00:00:01 |
    | 12 | INDEX FULL SCAN | I_USER# | 1 | | | 1 (0)| 00:00:01 |
    |* 13 | HASH JOIN | | 87035 | 9009K| | 296 (2)| 00:00:04 |
    | 14 | INDEX FULL SCAN | I_USER2 | 92 | 2024 | | 1 (0)| 00:00:01 |
    |* 15 | TABLE ACCESS FULL | OBJ$ | 87035 | 7139K| | 294 (1)| 00:00:04 |
    | 16 | NESTED LOOPS | | 1 | 29 | | 2 (0)| 00:00:01 |
    |* 17 | INDEX SKIP SCAN | I_USER2 | 1 | 20 | | 1 (0)| 00:00:01 |
    |* 18 | INDEX RANGE SCAN | I_OBJ4 | 1 | 9 | | 1 (0)| 00:00:01 |
    | 19 | NESTED LOOPS | | 1 | 105 | | 2 (0)| 00:00:01 |
    | 20 | TABLE ACCESS FULL | LINK$ | 1 | 88 | | 2 (0)| 00:00:01 |
    | 21 | TABLE ACCESS CLUSTER | USER$ | 1 | 17 | | 0 (0)| 00:00:01 |
    |* 22 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------------

    Predicate Information (identified by operation id):
    ---------------------------------------------------

    1 - access("OBJECT_ID"="OBJECT_ID")
    5 - filter(BITAND("S"."XPFLAGS",8388608)=8388608)
    6 - access("S"."OBJ#"=:B1)
    8 - access("EO"."OBJ#"=:B1)
    9 - filter("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND
    "O"."TYPE#"<>9 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14
    AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88 OR BITAND("U"."SPARE1",16)=0 OR
    ("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR
    "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR
    "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE'
    AND "U"."TYPE#"<>2 OR "U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_
    edition_id')) OR EXISTS (SELECT 0 FROM SYS."USER$" "U2",SYS."OBJ$" "O2" WHERE
    "O2"."OWNER#"="U2"."USER#" AND "O2"."TYPE#"=88 AND "O2"."DATAOBJ#"=:B1 AND "U2"."TYPE#"=2 AND
    "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))))
    10 - access("O"."SPARE3"="U"."USER#")
    13 - access("O"."OWNER#"="U"."USER#")
    15 - filter("O"."TYPE#"<>10 AND "O"."NAME"<>'_NEXT_OBJECT' AND
    "O"."NAME"<>'_default_auditing_options_' AND "O"."LINKNAME" IS NULL AND
    BITAND("O"."FLAGS",128)=0)
    17 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition
    _id')))
    filter("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition
    _id')))
    18 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
    22 - access("L"."OWNER#"="U"."USER#")

    Note
    -----
    - dynamic sampling used for this statement (level=2)

    大表not exists:

    SQL> select * from dba_objects where not exists
     (select object_id from not_exists_b where not_exists_b.object_id = dba_objects.object_id);
    Elapsed: 00:00:00.03

    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 465920853

    -------------------------------------------------------------------------------------------------------
    | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time |
    -------------------------------------------------------------------------------------------------------
    | 0 | SELECT STATEMENT | | 87034 | 18M| | 1445 (1)| 00:00:18 |
    |* 1 | HASH JOIN RIGHT ANTI | | 87034 | 18M| 1032K| 1445 (1)| 00:00:18 |
    | 2 | TABLE ACCESS FULL | NOT_EXISTS_B | 42206 | 535K| | 192 (0)| 00:00:03 |
    | 3 | VIEW | DBA_OBJECTS | 87036 | 17M| | 301 (1)| 00:00:04 |
    | 4 | UNION-ALL | | | | | | |
    |* 5 | TABLE ACCESS BY INDEX ROWID| SUM$ | 1 | 9 | | 1 (0)| 00:00:01 |
    |* 6 | INDEX UNIQUE SCAN | I_SUM$_1 | 1 | | | 0 (0)| 00:00:01 |
    | 7 | TABLE ACCESS BY INDEX ROWID| OBJ$ | 1 | 30 | | 3 (0)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_OBJ1 | 1 | | | 2 (0)| 00:00:01 |
    |* 9 | FILTER | | | | | | |
    |* 10 | HASH JOIN | | 87035 | 10M| | 299 (2)| 00:00:04 |
    | 11 | TABLE ACCESS CLUSTER | USER$ | 92 | 1564 | | 3 (0)| 00:00:01 |
    | 12 | INDEX FULL SCAN | I_USER# | 1 | | | 1 (0)| 00:00:01 |
    |* 13 | HASH JOIN | | 87035 | 9009K| | 296 (2)| 00:00:04 |
    | 14 | INDEX FULL SCAN | I_USER2 | 92 | 2024 | | 1 (0)| 00:00:01 |
    |* 15 | TABLE ACCESS FULL | OBJ$ | 87035 | 7139K| | 294 (1)| 00:00:04 |
    | 16 | NESTED LOOPS | | 1 | 29 | | 2 (0)| 00:00:01 |
    |* 17 | INDEX SKIP SCAN | I_USER2 | 1 | 20 | | 1 (0)| 00:00:01 |
    |* 18 | INDEX RANGE SCAN | I_OBJ4 | 1 | 9 | | 1 (0)| 00:00:01 |
    | 19 | NESTED LOOPS | | 1 | 105 | | 2 (0)| 00:00:01 |
    | 20 | TABLE ACCESS FULL | LINK$ | 1 | 88 | | 2 (0)| 00:00:01 |
    | 21 | TABLE ACCESS CLUSTER | USER$ | 1 | 17 | | 0 (0)| 00:00:01 |
    |* 22 | INDEX UNIQUE SCAN | I_USER# | 1 | | | 0 (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------------

    Predicate Information (identified by operation id):
    ---------------------------------------------------

    1 - access("NOT_EXISTS_B"."OBJECT_ID"="DBA_OBJECTS"."OBJECT_ID")
    5 - filter(BITAND("S"."XPFLAGS",8388608)=8388608)
    6 - access("S"."OBJ#"=:B1)
    8 - access("EO"."OBJ#"=:B1)
    9 - filter("O"."TYPE#"<>4 AND "O"."TYPE#"<>5 AND "O"."TYPE#"<>7 AND "O"."TYPE#"<>8 AND
    "O"."TYPE#"<>9 AND "O"."TYPE#"<>11 AND "O"."TYPE#"<>12 AND "O"."TYPE#"<>13 AND "O"."TYPE#"<>14
    AND "O"."TYPE#"<>22 AND "O"."TYPE#"<>87 AND "O"."TYPE#"<>88 OR BITAND("U"."SPARE1",16)=0 OR
    ("O"."TYPE#"=4 OR "O"."TYPE#"=5 OR "O"."TYPE#"=7 OR "O"."TYPE#"=8 OR "O"."TYPE#"=9 OR
    "O"."TYPE#"=10 OR "O"."TYPE#"=11 OR "O"."TYPE#"=12 OR "O"."TYPE#"=13 OR "O"."TYPE#"=14 OR
    "O"."TYPE#"=22 OR "O"."TYPE#"=87) AND (SYS_CONTEXT('userenv','current_edition_name')='ORA$BASE'
    AND "U"."TYPE#"<>2 OR "U"."TYPE#"=2 AND "U"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_
    edition_id')) OR EXISTS (SELECT 0 FROM SYS."USER$" "U2",SYS."OBJ$" "O2" WHERE
    "O2"."OWNER#"="U2"."USER#" AND "O2"."TYPE#"=88 AND "O2"."DATAOBJ#"=:B1 AND "U2"."TYPE#"=2 AND
    "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition_id')))))
    10 - access("O"."SPARE3"="U"."USER#")
    13 - access("O"."OWNER#"="U"."USER#")
    15 - filter("O"."TYPE#"<>10 AND "O"."NAME"<>'_NEXT_OBJECT' AND
    "O"."NAME"<>'_default_auditing_options_' AND "O"."LINKNAME" IS NULL AND
    BITAND("O"."FLAGS",128)=0)
    17 - access("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition
    _id')))
    filter("U2"."TYPE#"=2 AND "U2"."SPARE2"=TO_NUMBER(SYS_CONTEXT('userenv','current_edition
    _id')))
    18 - access("O2"."DATAOBJ#"=:B1 AND "O2"."TYPE#"=88 AND "O2"."OWNER#"="U2"."USER#")
    22 - access("L"."OWNER#"="U"."USER#")

    Note
    -----
    - dynamic sampling used for this statement (level=2)

     5万行记录的小表用not in,not exists 消耗的成本都是1445。

    3、结论:

    在11g的时候,无论not in 还是not exists,都可以走到Oracle比较先进高效的anti反连接算法;所以网络上的谣言需要慎重分析。

  • 相关阅读:
    高斯模糊原理,算法
    SIFT算法详解
    第五章:状态图
    ANTLR4权威指南
    第八章:包图,组件图,部署图
    棋盘n皇后问题-递归
    普通页面引入React(使用和不使用JSX)
    浏览器环境
    DevTool-Network
    优化浏览器渲染
  • 原文地址:https://www.cnblogs.com/hmwh/p/9516567.html
Copyright © 2020-2023  润新知