[20190306]奇怪的查詢結果.txt

来源:https://www.cnblogs.com/lfree/archive/2019/03/06/10481541.html
-Advertisement-
Play Games

[20190306]奇怪的查詢結果.txt--//鏈接http://www.itpub.net/thread-2108588-1-1.html提到一個非常古怪的問題,我自己重覆測試看看:1.環境:SCOTT@book> @ ver1PORT_STRING VERSION BANNER x86_64/ ...


[20190306]奇怪的查詢結果.txt

--//鏈接http://www.itpub.net/thread-2108588-1-1.html提到一個非常古怪的問題,我自己重覆測試看看:

1.環境:
SCOTT@book> @ ver1
PORT_STRING                    VERSION        BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx            11.2.0.4.0     Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

SYS@book> select * from dba_tab_modifications where table_name = 'OBJ$';
no rows selected

SYS@book> select * from dba_tab_modifications where table_name = 'OBJ$' and table_owner='SYS';
TABLE_OWNER TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP           TRU DROP_SEGMENTS
----------- ---------- -------------- ----------------- ------- ------- ------- ------------------- --- -------------
SYS         OBJ$                                             22      65      20 2019-03-05 22:24:14 NO              0

--//加入條件table_owner='SYS';反而查詢到結果.前面加入提示rule,也可以查詢到.明顯出了問題.
SYS@book> select /*+ rule */ * from dba_tab_modifications where table_name = 'OBJ$';
TABLE_OWNER TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS UPDATES DELETES TIMESTAMP           TRU DROP_SEGMENTS
----------- ---------- -------------- ----------------- ------- ------- ------- ------------------- --- -------------
SYS         OBJ$                                             22      65      20 2019-03-05 22:24:14 NO              0

SYS@book> ANALYZE TABLE sys.obj$ VALIDATE STRUCTURE CASCADE;
Table analyzed.

--//sys.obj$表以及索引都沒有問題.dba_tab_modifications裡面涉及的表我都分析校驗一次,沒有問題.

2.分析看看:

SYS@book> alter session set statistics_level=all ;
Session altered.

SYS@book> select * from dba_tab_modifications where table_name = 'OBJ$' ;
no rows selected

SYS@book> @ dpc '' outline
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  cb8hkhvh62mpu, child number 0
-------------------------------------
select * from dba_tab_modifications where table_name = 'OBJ$'
Plan hash value: 4248094259
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                          | Name               | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                   |                    |      1 |        |       |   104 (100)|          |      0 |00:00:00.01 |     121 |       |       |          |
|*  1 |  HASH JOIN                         |                    |      1 |      5 |   595 |   104   (0)| 00:00:02 |      0 |00:00:00.01 |     121 |  1079K|  1079K|  408K (0)|
|*  2 |   HASH JOIN                        |                    |      1 |      5 |   470 |   102   (0)| 00:00:02 |      1 |00:00:00.01 |     118 |  1483K|  1483K|  432K (0)|
|   3 |    VIEW                            | VW_JF_SET$35EDC1EA |      1 |      5 |   385 |    99   (0)| 00:00:02 |      1 |00:00:00.01 |     112 |       |       |          |
|   4 |     UNION-ALL                      |                    |      1 |        |       |            |          |      1 |00:00:00.01 |     112 |       |       |          |
|   5 |     @NESTED LOOPS                  |                    |      1 |      2 |    76 |    32   (0)| 00:00:01 |      1 |00:00:00.01 |      39 |       |       |          |
|*  6 |     @ INDEX SKIP SCAN              | I_OBJ2             |      1 |      2 |    66 |    31   (0)| 00:00:01 |      1 |00:00:00.01 |      36 |       |       |          |
|   7 |     @ TABLE ACCESS CLUSTER         | TAB$               |      1 |      1 |     5 |     1   (0)| 00:00:01 |      1 |00:00:00.01 |       3 |       |       |          |
|*  8 |     @  INDEX UNIQUE SCAN           | I_OBJ#             |      1 |      1 |       |     0   (0)|          |      1 |00:00:00.01 |       2 |       |       |          |
|*  9 |     @INDEX SKIP SCAN               | I_OBJ5             |      1 |      1 |    39 |    31   (0)| 00:00:01 |      0 |00:00:00.01 |      36 |       |       |          |
|  10 |     @NESTED LOOPS                  |                    |      1 |      2 |   100 |    36   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          |
|  11 |     @ NESTED LOOPS                 |                    |      1 |      2 |   100 |    36   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          |
|  12 |     @  NESTED LOOPS                |                    |      1 |      2 |    86 |    32   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          |
|* 13 |     @   INDEX SKIP SCAN            | I_OBJ2             |      1 |      2 |    70 |    31   (0)| 00:00:01 |      1 |00:00:00.01 |      36 |       |       |          |
|  14 |     @   TABLE ACCESS BY INDEX ROWID| TABSUBPART$        |      1 |      1 |     8 |     1   (0)| 00:00:01 |      0 |00:00:00.01 |       1 |       |       |          |
|* 15 |     @    INDEX UNIQUE SCAN         | I_TABSUBPART$_OBJ$ |      1 |      1 |       |     0   (0)|          |      0 |00:00:00.01 |       1 |       |       |          |
|* 16 |     @  INDEX RANGE SCAN            | I_OBJ1             |      0 |      1 |       |     1   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |       |       |          |
|  17 |     @ TABLE ACCESS BY INDEX ROWID  | OBJ$               |      0 |      1 |     7 |     2   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |       |       |          |
|  18 |    TABLE ACCESS FULL               | USER$              |      1 |     99 |  1683 |     3   (0)| 00:00:01 |     99 |00:00:00.01 |       6 |       |       |          |
|  19 |   TABLE ACCESS FULL                | MON_MODS_ALL$      |      1 |    124 |  3100 |     2   (0)| 00:00:01 |    130 |00:00:00.01 |       3 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--//說明:執行計劃裡面的@是我人為加入的.VW_JF_SET表示因式分解.
--//我的感覺是執行計劃把sys.mon_mods_all$ m,sys.user$ u拿出來最後連接.
--//看id=2,A-rows=1,也可以看出有結果的來之union all的第1部分(視圖定義看下麵).
--//也就是最後與MON_MODS_ALL$連接時,沒有記錄輸出.
--//看id=1的連接條件是   1 - access("ITEM_2"="M"."OBJ#").
SYS@book> select * from MON_MODS_ALL$ m where M.OBJ#=18;
      OBJ#    INSERTS    UPDATES    DELETES TIMESTAMP                FLAGS DROP_SEGMENTS
---------- ---------- ---------- ---------- ------------------- ---------- -------------
        18         22         65         20 2019-03-05 22:24:14          0             0
--//為什麼最後做hash join(id=1)後,實際行數是0,不理解.
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$4CC7D0F8
   3 - SET$35EDC1EA / VW_JF_SET$35EDC1EA@SEL$A33807FD
   4 - SET$35EDC1EA
   5 - SEL$61D13A11
   6 - SEL$61D13A11 / O@SEL$2
   7 - SEL$61D13A11 / T@SEL$2
   8 - SEL$61D13A11 / T@SEL$2
   9 - SEL$61BB150F / O@SEL$3
  10 - SEL$5962AF70
  13 - SEL$5962AF70 / O@SEL$4
  14 - SEL$5962AF70 / TSP@SEL$4
  15 - SEL$5962AF70 / TSP@SEL$4
  16 - SEL$5962AF70 / O2@SEL$4
  17 - SEL$5962AF70 / O2@SEL$4
  18 - SEL$4CC7D0F8 / U@SEL$2
  19 - SEL$4CC7D0F8 / M@SEL$2

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.2.0.4')
      DB_VERSION('11.2.0.4')
      ALL_ROWS
      OUTLINE_LEAF(@"SEL$5962AF70")
      OUTLINE_LEAF(@"SEL$61BB150F")
      OUTLINE_LEAF(@"SEL$61D13A11")
      OUTLINE_LEAF(@"SET$35EDC1EA")
      OUTLINE_LEAF(@"SEL$4CC7D0F8")
      MERGE(@"SEL$58D8A5DB")
      OUTLINE(@"SEL$420E0780")
      OUTLINE(@"SEL$73E92AB2")
      OUTLINE(@"SEL$A33807FD")
      OUTLINE(@"SET$E5581402")
      FACTORIZE_JOIN(@"SET$1"("M"@"SEL$2" "M"@"SEL$3" "M"@"SEL$4") ("U"@"SEL$2" "U"@"SEL$3" "U"@"SEL$4"))
      OUTLINE(@"SEL$1")
      OUTLINE(@"SEL$58D8A5DB")
      MERGE(@"SEL$38196F71")
      OUTLINE(@"SEL$4")
      OUTLINE(@"SEL$3")
      OUTLINE(@"SEL$2")
      OUTLINE(@"SET$1")
      OUTLINE(@"SEL$F9F648E4")
      OUTLINE(@"SEL$38196F71")
      NO_ACCESS(@"SEL$4CC7D0F8" "VW_JF_SET$35EDC1EA"@"SEL$A33807FD")
      FULL(@"SEL$4CC7D0F8" "U"@"SEL$2")
      FULL(@"SEL$4CC7D0F8" "M"@"SEL$2")
      LEADING(@"SEL$4CC7D0F8" "VW_JF_SET$35EDC1EA"@"SEL$A33807FD" "U"@"SEL$2" "M"@"SEL$2")
      USE_HASH(@"SEL$4CC7D0F8" "U"@"SEL$2")
      USE_HASH(@"SEL$4CC7D0F8" "M"@"SEL$2")
      INDEX_SS(@"SEL$61D13A11" "O"@"SEL$2" ("OBJ$"."OWNER#" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME" "OBJ$"."SUBNAME" "OBJ$"."TYPE#"
              "OBJ$"."SPARE3" "OBJ$"."OBJ#"))
      INDEX(@"SEL$61D13A11" "T"@"SEL$2" "I_OBJ#")
      LEADING(@"SEL$61D13A11" "O"@"SEL$2" "T"@"SEL$2")
      USE_NL(@"SEL$61D13A11" "T"@"SEL$2")
      INDEX_SS(@"SEL$61BB150F" "O"@"SEL$3" ("OBJ$"."SPARE3" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."TYPE#" "OBJ$"."OWNER#" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME"
              "OBJ$"."SUBNAME" "OBJ$"."OBJ#"))
      INDEX_SS(@"SEL$5962AF70" "O"@"SEL$4" ("OBJ$"."OWNER#" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME" "OBJ$"."SUBNAME" "OBJ$"."TYPE#"
              "OBJ$"."SPARE3" "OBJ$"."OBJ#"))
      INDEX_RS_ASC(@"SEL$5962AF70" "TSP"@"SEL$4" ("TABSUBPART$"."OBJ#"))
      INDEX(@"SEL$5962AF70" "O2"@"SEL$4" ("OBJ$"."OBJ#" "OBJ$"."OWNER#" "OBJ$"."TYPE#"))
      LEADING(@"SEL$5962AF70" "O"@"SEL$4" "TSP"@"SEL$4" "O2"@"SEL$4")
      USE_NL(@"SEL$5962AF70" "TSP"@"SEL$4")
      USE_NL(@"SEL$5962AF70" "O2"@"SEL$4")
      NLJ_BATCHING(@"SEL$5962AF70" "O2"@"SEL$4")
      END_OUTLINE_DATA
  */

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

   1 - access("ITEM_2"="M"."OBJ#")
   2 - access("ITEM_1"="U"."USER#")
   6 - access("O"."NAME"='OBJ$')
       filter("O"."NAME"='OBJ$')
   8 - access("O"."OBJ#"="T"."OBJ#")
   9 - access("O"."NAME"='OBJ$' AND "O"."TYPE#"=19)
       filter(("O"."NAME"='OBJ$' AND "O"."TYPE#"=19))
  13 - access("O"."NAME"='OBJ$')
       filter("O"."NAME"='OBJ$')
  15 - access("O"."OBJ#"="TSP"."OBJ#")
  16 - access("O2"."OBJ#"="TSP"."POBJ#")
119 rows selected.

--//如果查看SYS.DBA_TAB_MODIFICATIONS視圖定義:
CREATE OR REPLACE FORCE VIEW SYS.DBA_TAB_MODIFICATIONS
(
   TABLE_OWNER
  ,TABLE_NAME
  ,PARTITION_NAME
  ,SUBPARTITION_NAME
  ,INSERTS
  ,UPDATES
  ,DELETES
  ,TIMESTAMP
  ,TRUNCATED
  ,DROP_SEGMENTS
)
AS
   SELECT u.name
         ,o.name
         ,NULL
         ,NULL
         ,m.inserts
         ,m.updates
         ,m.deletes
         ,m.timestamp
         ,DECODE (BITAND (m.flags, 1), 1, 'YES', 'NO')
         ,m.drop_segments
     FROM sys.mon_mods_all$ m
         ,sys.obj$ o
         ,sys.tab$ t
         ,sys.user$ u
    WHERE o.obj# = m.obj# AND o.obj# = t.obj# AND o.owner# = u.user#
   UNION ALL
   SELECT u.name
         ,o.name
         ,o.subname
         ,NULL
         ,m.inserts
         ,m.updates
         ,m.deletes
         ,m.timestamp
         ,DECODE (BITAND (m.flags, 1), 1, 'YES', 'NO')
         ,m.drop_segments
     FROM sys.mon_mods_all$ m, sys.obj$ o, sys.user$ u
    WHERE o.owner# = u.user# AND o.obj# = m.obj# AND o.type# = 19
   UNION ALL
   SELECT u.name
         ,o.name
         ,o2.subname
         ,o.subname
         ,m.inserts
         ,m.updates
         ,m.deletes
         ,m.timestamp
         ,DECODE (BITAND (m.flags, 1), 1, 'YES', 'NO')
         ,m.drop_segments
     FROM sys.mon_mods_all$ m
         ,sys.obj$ o
         ,sys.tabsubpart$ tsp
         ,sys.obj$ o2
         ,sys.user$ u
    WHERE     o.obj# = m.obj#
          AND o.owner# = u.user#
          AND o.obj# = tsp.obj#
          AND o2.obj# = tsp.pobj#;
--//分3部分,大概猜測第1部分關於普通表.第2部分是o.type# = 19??.第3部分是有分區表的情況.

--//單獨建立視圖SYS.DBA_TAB_MODIFICATIONSx:
CREATE  VIEW SYS.DBA_TAB_MODIFICATIONSx
(
   TABLE_OWNER
  ,TABLE_NAME
  ,PARTITION_NAME
  ,SUBPARTITION_NAME
  ,INSERTS
  ,UPDATES
  ,DELETES
  ,TIMESTAMP
  ,TRUNCATED
  ,DROP_SEGMENTS
)
AS
   SELECT u.name
         ,o.name
         ,NULL
         ,NULL
         ,m.inserts
         ,m.updates
         ,m.deletes
         ,m.timestamp
         ,DECODE (BITAND (m.flags, 1), 1, 'YES', 'NO')
         ,m.drop_segments
     FROM sys.mon_mods_all$ m
         ,sys.obj$ o
         ,sys.tab$ t
         ,sys.user$ u
    WHERE o.obj# = m.obj# AND o.obj# = t.obj# AND o.owner# = u.user#;

SYS@book> select  * from dba_tab_modificationsx where table_name = 'OBJ$' ;
TABLE_OWNER                    TABLE_NAME P S    INSERTS    UPDATES    DELETES TIMESTAMP           TRU DROP_SEGMENTS
------------------------------ ---------- - - ---------- ---------- ---------- ------------------- --- -------------
SYS                            OBJ$                   22         65         20 2019-03-05 22:24:14 NO              0

--//明顯顯示信息來自SYS.DBA_TAB_MODIFICATIONS的union all第1部分.
--//使用提示保證執行計劃一致.
SYS@book> select /*+ full("M"@"SEL$2") full("U"@"SEL$2") LEADING(@"SEL$F5BB74E1" "O"@"SEL$2" "T"@"SEL$2" "U"@"SEL$2" "M"@"SEL$2" ) */ * from dba_tab_modificationsx where table_name = 'OBJ$';
TABLE_OWNER                    TABLE_NAME P S    INSERTS    UPDATES    DELETES TIMESTAMP           TRU DROP_SEGMENTS
------------------------------ ---------- - - ---------- ---------- ---------- ------------------- --- -------------
SYS                            OBJ$                   22         65         20 2019-03-05 22:24:14 NO              0
--//嗯,有結果輸出,為什麼?

SYS@book> @ dpc '' outline
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  dp6dk67ugzkct, child number 0
-------------------------------------
select /*+ full("M"@"SEL$2") full("U"@"SEL$2") LEADING(@"SEL$F5BB74E1"
"O"@"SEL$2" "T"@"SEL$2" "U"@"SEL$2" "M"@"SEL$2" ) */ * from
dba_tab_modificationsx where table_name = 'OBJ$'

Plan hash value: 1913090444

--------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation               | Name          | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
--------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |               |      1 |        |       |    37 (100)|          |      1 |00:00:00.01 |      49 |       |       |          |
|*  1 |  HASH JOIN              |               |      1 |      2 |   160 |    37   (0)| 00:00:01 |      1 |00:00:00.01 |      49 |  1557K|  1557K|  673K (0)|
|*  2 |   HASH JOIN             |               |      1 |      2 |   110 |    35   (0)| 00:00:01 |      1 |00:00:00.01 |      45 |  1645K|  1645K|  737K (0)|
|   3 |    NESTED LOOPS         |               |      1 |      2 |    76 |    32   (0)| 00:00:01 |      1 |00:00:00.01 |      39 |       |       |          |
|*  4 |     INDEX SKIP SCAN     | I_OBJ2        |      1 |      2 |    66 |    31   (0)| 00:00:01 |      1 |00:00:00.01 |      36 |       |       |          |
|   5 |     TABLE ACCESS CLUSTER| TAB$          |      1 |      1 |     5 |     1   (0)| 00:00:01 |      1 |00:00:00.01 |       3 |       |       |          |
|*  6 |      INDEX UNIQUE SCAN  | I_OBJ#        |      1 |      1 |       |     0   (0)|          |      1 |00:00:00.01 |       2 |       |       |          |
|   7 |    TABLE ACCESS FULL    | USER$         |      1 |     99 |  1683 |     3   (0)| 00:00:01 |     99 |00:00:00.01 |       6 |       |       |          |
|   8 |   TABLE ACCESS FULL     | MON_MODS_ALL$ |      1 |    124 |  3100 |     2   (0)| 00:00:01 |    130 |00:00:00.01 |       4 |       |       |          |
--------------------------------------------------------------------------------------------------------------------------------------------------------------
--//執行計劃與上面一致.

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$F5BB74E1
   4 - SEL$F5BB74E1 / O@SEL$2
   5 - SEL$F5BB74E1 / T@SEL$2
   6 - SEL$F5BB74E1 / T@SEL$2
   7 - SEL$F5BB74E1 / U@SEL$2
   8 - SEL$F5BB74E1 / M@SEL$2

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.2.0.4')
      DB_VERSION('11.2.0.4')
      ALL_ROWS
      OUTLINE_LEAF(@"SEL$F5BB74E1")
      MERGE(@"SEL$2")
      OUTLINE(@"SEL$1")
      OUTLINE(@"SEL$2")
      INDEX_SS(@"SEL$F5BB74E1" "O"@"SEL$2" ("OBJ$"."OWNER#" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME" "OBJ$"."SUBNAME"
              "OBJ$"."TYPE#" "OBJ$"."SPARE3" "OBJ$"."OBJ#"))
      INDEX(@"SEL$F5BB74E1" "T"@"SEL$2" "I_OBJ#")
      FULL(@"SEL$F5BB74E1" "U"@"SEL$2")
      FULL(@"SEL$F5BB74E1" "M"@"SEL$2")
      LEADING(@"SEL$F5BB74E1" "O"@"SEL$2" "T"@"SEL$2" "U"@"SEL$2" "M"@"SEL$2")
      USE_NL(@"SEL$F5BB74E1" "T"@"SEL$2")
      USE_HASH(@"SEL$F5BB74E1" "U"@"SEL$2")
      USE_HASH(@"SEL$F5BB74E1" "M"@"SEL$2")
      END_OUTLINE_DATA
  */

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

   1 - access("O"."OBJ#"="M"."OBJ#")
   2 - access("O"."OWNER#"="U"."USER#")
   4 - access("O"."NAME"='OBJ$')
       filter("O"."NAME"='OBJ$')
   6 - access("O"."OBJ#"="T"."OBJ#")

--//我僅僅能估計Oracle 連接因式分解有bug,在連接時報錯.

3.做一個10053跟蹤分析看看:

SYS@book> @ 10053x cb8hkhvh62mpu 0
PL/SQL procedure successfully completed.

Final query after transformations:******* UNPARSED QUERY IS *******
--//如下:我做了格式化處理:
SELECT "U"."NAME" "TABLE_OWNER"
      ,"VW_JF_SET$35EDC1EA"."ITEM_3" "TABLE_NAME"
      ,"VW_JF_SET$35EDC1EA"."ITEM_4" "PARTITION_NAME"
      ,"VW_JF_SET$35EDC1EA"."ITEM_5" "SUBPARTITION_NAME"
      ,"M"."INSERTS" "INSERTS"
      ,"M"."UPDATES" "UPDATES"
      ,"M"."DELETES" "DELETES"
      ,"M"."TIMESTAMP" "TIMESTAMP"
      ,DECODE (BITAND ("M"."FLAGS", 1), 1, 'YES', 'NO') "TRUNCATED"
      ,"M"."DROP_SEGMENTS" "DROP_SEGMENTS"
  FROM ( (SELECT "O"."OWNER#" "ITEM_1"
                ,"O"."OBJ#" "ITEM_2"
                ,"O"."NAME" "ITEM_3"
                ,NULL "ITEM_4"
                ,NULL "ITEM_5"
            FROM "SYS"."TAB$" "T", "SYS"."OBJ$" "O"
           WHERE "O"."NAME" = 'OBJ$' AND "O"."OBJ#" = "T"."OBJ#")
        UNION ALL
        ( (SELECT "O"."OWNER#" "ITEM_2"
                 ,"O"."OBJ#" "ITEM_1"
                 ,"O"."NAME" "ITEM_3"
                 ,"O"."SUBNAME" "ITEM_4"
                 ,NULL "ITEM_5"
             FROM "SYS"."OBJ$" "O"
            WHERE "O"."NAME" = 'OBJ$' AND "O"."TYPE#" = 19)
         UNION ALL
         (SELECT "O"."OWNER#" "ITEM_1"
                ,"O"."OBJ#" "ITEM_2"
                ,"O"."NAME" "ITEM_3"
                ,"O2"."SUBNAME" "ITEM_4"
                ,"O"."SUBNAME" "ITEM_5"
            FROM "SYS"."OBJ$" "O"
                ,"SYS"."OBJ$" "O2"
                ,"SYS"."TABSUBPART$" "TSP"
           WHERE     "O"."NAME" = 'OBJ$'
                 AND "O2"."OBJ#" = "TSP"."POBJ#"
                 AND "O"."OBJ#" = "TSP"."OBJ#"))) "VW_JF_SET$35EDC1EA"
      ,"SYS"."MON_MODS_ALL$" "M"
      ,"SYS"."USER$" "U"
 WHERE     "VW_JF_SET$35EDC1EA"."ITEM_2" = "M"."OBJ#"
       AND "VW_JF_SET$35EDC1EA"."ITEM_1" = "U"."USER#";

--//我直接執行OK.
TABLE_OWNER TABLE_NAME PARTITION_NAME SUBPARTITION_NAME INSERTS    UPDATES    DELETES TIMESTAMP           TRU DROP_SEGMENTS
----------- ---------- -------------- ----------------- ------- ---------- ---------- ------------------- --- -------------
SYS         OBJ$                                             22         65         20 2019-03-05 22:24:14 NO              0


--//執行計劃如下:
Plan hash value: 1913316274

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @---------
| Id  | Operation                          | Name               | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem | @Buffers |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @---------
|   0 | SELECT STATEMENT                   |                    |      1 |        |       |   104 (100)|          |      1 |00:00:00.01 |     122 |       |       |          | @    121 |
|*  1 |  HASH JOIN                         |                    |      1 |      5 |   595 |   104   (0)| 00:00:02 |      1 |00:00:00.01 |     122 |  1421K|  1421K|  652K (0)| @    121 |
|*  2 |   HASH JOIN                        |                    |      1 |      5 |   470 |   102   (0)| 00:00:02 |      1 |00:00:00.01 |     118 |  1483K|  1483K|  740K (0)| @    118 |
|   3 |    VIEW                            |                    |      1 |      5 |   385 |    99   (0)| 00:00:02 |      1 |00:00:00.01 |     112 |       |       |          | @    112 |
|   4 |     UNION-ALL                      |                    |      1 |        |       |            |          |      1 |00:00:00.01 |     112 |       |       |          | @    112 |
|   5 |      NESTED LOOPS                  |                    |      1 |      2 |    76 |    32   (0)| 00:00:01 |      1 |00:00:00.01 |      39 |       |       |          | @     39 |
|*  6 |       INDEX SKIP SCAN              | I_OBJ2             |      1 |      2 |    66 |    31   (0)| 00:00:01 |      1 |00:00:00.01 |      36 |       |       |          | @     36 |
|   7 |       TABLE ACCESS CLUSTER         | TAB$               |      1 |      1 |     5 |     1   (0)| 00:00:01 |      1 |00:00:00.01 |       3 |       |       |          | @      3 |
|*  8 |        INDEX UNIQUE SCAN           | I_OBJ#             |      1 |      1 |       |     0   (0)|          |      1 |00:00:00.01 |       2 |       |       |          | @      2 |
|*  9 |      INDEX SKIP SCAN               | I_OBJ5             |      1 |      1 |    39 |    31   (0)| 00:00:01 |      0 |00:00:00.01 |      36 |       |       |          | @     36 |
|  10 |      NESTED LOOPS                  |                    |      1 |      2 |   100 |    36   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          | @     37 |
|  11 |       NESTED LOOPS                 |                    |      1 |      2 |   100 |    36   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          | @     37 |
|  12 |        NESTED LOOPS                |                    |      1 |      2 |    86 |    32   (0)| 00:00:01 |      0 |00:00:00.01 |      37 |       |       |          | @     37 |
|* 13 |         INDEX SKIP SCAN            | I_OBJ2             |      1 |      2 |    70 |    31   (0)| 00:00:01 |      1 |00:00:00.01 |      36 |       |       |          | @     36 |
|  14 |         TABLE ACCESS BY INDEX ROWID| TABSUBPART$        |      1 |      1 |     8 |     1   (0)| 00:00:01 |      0 |00:00:00.01 |       1 |       |       |          | @      1 |
|* 15 |          INDEX UNIQUE SCAN         | I_TABSUBPART$_OBJ$ |      1 |      1 |       |     0   (0)|          |      0 |00:00:00.01 |       1 |       |       |          | @      1 |
|* 16 |        INDEX RANGE SCAN            | I_OBJ1             |      0 |      1 |       |     1   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |       |       |          | @      0 |
|  17 |       TABLE ACCESS BY INDEX ROWID  | OBJ$               |      0 |      1 |     7 |     2   (0)| 00:00:01 |      0 |00:00:00.01 |       0 |       |       |          | @      0 |
|  18 |    TABLE ACCESS FULL               | USER$              |      1 |     99 |  1683 |     3   (0)| 00:00:01 |     99 |00:00:00.01 |       6 |       |       |          | @      6 |
|  19 |   TABLE ACCESS FULL                | MON_MODS_ALL$      |      1 |    124 |  3100 |     2   (0)| 00:00:01 |    130 |00:00:00.01 |       4 |       |       |          | @      3 |
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @---------
--//執行計劃與上面完成一致.
--//奇怪的地方id=19,buffers=4,前面是3?

Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------

   1 - SEL$1
   3 - SET$1 / VW_JF_SET$35EDC1EA@SEL$1
   4 - SET$1
   5 - SEL$2
   6 - SEL$2 / O@SEL$2
   7 - SEL$2 / T@SEL$2
   8 - SEL$2 / T@SEL$2
   9 - SEL$3 / O@SEL$3
  10 - SEL$4
  13 - SEL$4 / O@SEL$4
  14 - SEL$4 / TSP@SEL$4
  15 - SEL$4 / TSP@SEL$4
  16 - SEL$4 / O2@SEL$4
  17 - SEL$4 / O2@SEL$4
  18 - SEL$1 / U@SEL$1
  19 - SEL$1 / M@SEL$1

Outline Data
-------------

  /*+
      BEGIN_OUTLINE_DATA
      IGNORE_OPTIM_EMBEDDED_HINTS
      OPTIMIZER_FEATURES_ENABLE('11.2.0.4')
      DB_VERSION('11.2.0.4')
      ALL_ROWS
      OUTLINE_LEAF(@"SEL$2")
      OUTLINE_LEAF(@"SEL$3")
      OUTLINE_LEAF(@"SEL$4")
      OUTLINE_LEAF(@"SET$1")
      OUTLINE_LEAF(@"SEL$1")
      NO_ACCESS(@"SEL$1" "VW_JF_SET$35EDC1EA"@"SEL$1")
      FULL(@"SEL$1" "U"@"SEL$1")
      FULL(@"SEL$1" "M"@"SEL$1")
      LEADING(@"SEL$1" "VW_JF_SET$35EDC1EA"@"SEL$1" "U"@"SEL$1" "M"@"SEL$1")
      USE_HASH(@"SEL$1" "U"@"SEL$1")
      USE_HASH(@"SEL$1" "M"@"SEL$1")
      INDEX_SS(@"SEL$4" "O"@"SEL$4" ("OBJ$"."OWNER#" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME" "OBJ$"."SUBNAME" "OBJ$"."TYPE#"
              "OBJ$"."SPARE3" "OBJ$"."OBJ#"))
      INDEX_RS_ASC(@"SEL$4" "TSP"@"SEL$4" ("TABSUBPART$"."OBJ#"))
      INDEX(@"SEL$4" "O2"@"SEL$4" ("OBJ$"."OBJ#" "OBJ$"."OWNER#" "OBJ$"."TYPE#"))
      LEADING(@"SEL$4" "O"@"SEL$4" "TSP"@"SEL$4" "O2"@"SEL$4")
      USE_NL(@"SEL$4" "TSP"@"SEL$4")
      USE_NL(@"SEL$4" "O2"@"SEL$4")
      NLJ_BATCHING(@"SEL$4" "O2"@"SEL$4")
      INDEX_SS(@"SEL$3" "O"@"SEL$3" ("OBJ$"."SPARE3" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."TYPE#" "OBJ$"."OWNER#" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME"
              "OBJ$"."SUBNAME" "OBJ$"."OBJ#"))
      INDEX_SS(@"SEL$2" "O"@"SEL$2" ("OBJ$"."OWNER#" "OBJ$"."NAME" "OBJ$"."NAMESPACE" "OBJ$"."REMOTEOWNER" "OBJ$"."LINKNAME" "OBJ$"."SUBNAME" "OBJ$"."TYPE#"
              "OBJ$"."SPARE3" "OBJ$"."OBJ#"))
      INDEX(@"SEL$2" "T"@"SEL$2" "I_OBJ#")
      LEADING(@"SEL$2" "O"@"SEL$2" "T"@"SEL$2")
      USE_NL(@"SEL$2" "T"@"SEL$2")
      END_OUTLINE_DATA
  */

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

   1 - access("VW_JF_SET$35EDC1EA"."ITEM_2"="M"."OBJ#")
   2 - access("VW_JF_SET$35EDC1EA"."ITEM_1"="U"."USER#")
   6 - access("O"."NAME"='OBJ$')
       filter("O"."NAME"='OBJ$')
   8 - access("O"."OBJ#"="T"."OBJ#")
   9 - access("O"."NAME"='OBJ$' AND "O"."TYPE#"=19)
       filter(("O"."NAME"='OBJ$' AND "O"."TYPE#"=19))
  13 - access("O"."NAME"='OBJ$')
       filter("O"."NAME"='OBJ$')
  15 - access("O"."OBJ#"="TSP"."OBJ#")
  16 - access("O2"."OBJ#"="TSP"."POBJ#")


4.貼一個有結果的執行計劃:
Plan hash value: 712189870
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                          | Name                | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                   |                     |      1 |        |       |   130 (100)|          |      1 |00:00:00.01 |     148 |       |       |          |
|*  1 |  HASH JOIN                         |                     |      1 |      5 |   720 |   130   (0)| 00:00:02 |      1 |00:00:00.01 |     148 |  2211K|  2211K|  444K (0)|
|   2 |   VIEW                             | VW_JF_SET$52E8A812  |      1 |      5 |   640 |   126   (0)| 00:00:02 |      1 |00:00:00.01 |     139 |       |       |          |
|   3 |    UNION-ALL                       |                     |      1 |        |       |            |          |      1 |00:00:00.01 |     139 |       |       |          |
|   4 |     NESTED LOOPS               

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 空查詢(empty search) —{}— 在功能上等價於使用 match_all 查詢, 正如其名字一樣,匹配所有文檔: match_all 查詢 match_all 查詢簡單的匹配所有文檔。在沒有指定查詢方式時,它是預設的查詢: 它經常與 filter 結合使用--例如,檢索收件箱里的所有郵件 ...
  • 可重覆讀隔離級別,不允許存在幻讀,該隔離級別之所以能夠有效防止幻讀現象的出現,是因為可重覆讀這個隔離級別有用到GAP鎖(間隙鎖)。 ...
  • 一、 MySQL+MyCat分庫分表 1 MyCat簡介 java編寫的資料庫中間件 Mycat運行環境需要JDK. Mycat是中間件.運行在代碼應用和MySQL資料庫之間的應用. 前身 : corba. 是阿裡開發的資料庫中間件.實現MySQL資料庫分庫分表集群管理的中間件.曾經出現過重大事故. ...
  • 1、創建一個maven工程 2、POM文件 ...
  • 在當前互聯網流行架構下,Redis、MongoDB等非關係型資料庫(NoSQL)正逐漸搶占更多的視野,然而正如其釋義(Not Only SQL)所說,NoSQL在當前仍然只作為傳統關係型資料庫的補充。當前的的大部分持久化場景下,關係型資料庫仍然占據不可替代的地位。因此,能夠設計出規範合理的關係數據表 ...
  • 需要一些前提條件: 1、對方的主機能被連接(如在同一區域網內) 2、需要知道對方資料庫IP、埠號、服務名 3、需要知道對方提供的管理資料庫的用戶名及密碼 連接方法: 1、在本地的oracle安裝目錄,找到tnsnames.ora文件,一般在~\oracle\product\10.2.0\db_1\ ...
  • 協同辦公衍生出的需求 1.業務需求 1.1.流程 先說業務流程: 現在辦公基本上都是諸如 之類的線上office來協同辦公,然後所有的線上文檔會有一份本地文件用來存儲和數據分析 1.2.需求 需求是這樣的: 希望企業系統和文職人員以及分析部能夠共同管理這些Excel表格,但不想耗費資源去開發OA之類 ...
  • 1,先到Oracle站點下載Instant Client : http://www.oracle.com/technology/global/cn/software/tech/oci/instantclient/index.html 依據你的操作系統選擇不同的Instant Client版本號 下載 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...