• 一个表空间使用率查询sql的优化


    话不多说,直接上运行计划:
    SQL> set lines 500;
    SQL> set pagesize 9999;
    SQL> set long 9999;
    SQL> select * from table(dbms_xplan.display_cursor('41348610',null,'advanced'));
    
    PLAN_TABLE_OUTPUT
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    HASH_VALUE  41348610, child number 0
    ------------------------------------
     SELECT D.TABLESPACE_NAME,         SPACE "Total(M)",         SPACE -
    NVL(FREE_SPACE, 0) "USED(M)",         ROUND((1 - NVL(FREE_SPACE, 0) /
    SPACE) * 100, 2) "USED(%)",         FREE_SPACE "FREE(M)"    FROM
    (SELECT TABLESPACE_NAME,                 ROUND(SUM(BYTES) / (1024 *
    1024), 2) SPACE,                 SUM(BLOCKS) BLOCKS            FROM
    DBA_DATA_FILES           GROUP BY TABLESPACE_NAME) D,         (SELECT
    TABLESPACE_NAME,                 ROUND(SUM(BYTES) / (1024 * 1024), 2)
    FREE_SPACE            FROM DBA_FREE_SPACE           GROUP BY
    TABLESPACE_NAME) F   WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
    UNION ALL --if have tempfile  SELECT D.TABLESPACE_NAME,         SPACE
    "Total(M)",         USED_SPACE "USED(M)",         ROUND(NVL(USED_SPACE,
    0) / SPACE * 100, 2) "USED(%)",         NVL(FREE_SPACE, 0) "FREE(M)"
    FROM (SELECT TABLESPACE_NAME,                 ROUND(SUM(BYTES) / (1024
    * 1024), 2) SPACE,                 SUM(BLOCKS) BLOCKS            FROM
    DBA_TEMP_FILES           GROUP BY T
    
    Plan hash value: 3967328987
    
    ----------------------------------------------------------------------------------------------------------
    | Id  | Operation                             | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                      |                  |       |       |    20 (100)|          |
    |   1 |  SORT ORDER BY                        |                  |     3 |   178 |    19  (22)| 00:00:01 |
    |   2 |   UNION-ALL                           |                  |       |       |            |          |
    |*  3 |    HASH JOIN OUTER                    |                  |     2 |   120 |    16  (19)| 00:00:01 |
    |   4 |     VIEW                              |                  |     2 |    60 |     5  (20)| 00:00:01 |
    |   5 |      HASH GROUP BY                    |                  |     2 |    68 |     5  (20)| 00:00:01 |
    |   6 |       VIEW                            | DBA_DATA_FILES   |     2 |    68 |     4   (0)| 00:00:01 |
    |   7 |        UNION-ALL                      |                  |       |       |            |          |
    |   8 |         NESTED LOOPS                  |                  |     1 |   356 |     2   (0)| 00:00:01 |
    |   9 |          NESTED LOOPS                 |                  |     1 |   341 |     1   (0)| 00:00:01 |
    |  10 |           NESTED LOOPS                |                  |     1 |   328 |     1   (0)| 00:00:01 |
    |* 11 |            FIXED TABLE FULL           | X$KCCFN          |     1 |   310 |     0   (0)|          |
    |* 12 |            TABLE ACCESS BY INDEX ROWID| FILE$            |     1 |    18 |     1   (0)| 00:00:01 |
    |* 13 |             INDEX UNIQUE SCAN         | I_FILE1          |     1 |       |     0   (0)|          |
    |* 14 |           FIXED TABLE FIXED INDEX     | X$KCCFE (ind:1)  |    20 |   260 |     0   (0)|          |
    |  15 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 16 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)|          |
    |  17 |         NESTED LOOPS                  |                  |     1 |   399 |     2   (0)| 00:00:01 |
    |  18 |          NESTED LOOPS                 |                  |     1 |   386 |     2   (0)| 00:00:01 |
    |  19 |           NESTED LOOPS                |                  |     1 |   377 |     1   (0)| 00:00:01 |
    |  20 |            NESTED LOOPS               |                  |     1 |   362 |     0   (0)|          |
    |* 21 |             FIXED TABLE FULL          | X$KCCFN          |     1 |   310 |     0   (0)|          |
    |* 22 |             FIXED TABLE FIXED INDEX   | X$KTFBHC (ind:1) |     1 |    52 |     0   (0)|          |
    |  23 |            TABLE ACCESS CLUSTER       | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 24 |             INDEX UNIQUE SCAN         | I_TS#            |     1 |       |     0   (0)|          |
    |* 25 |           TABLE ACCESS BY INDEX ROWID | FILE$            |     1 |     9 |     1   (0)| 00:00:01 |
    |* 26 |            INDEX UNIQUE SCAN          | I_FILE1          |     1 |       |     0   (0)|          |
    |* 27 |          FIXED TABLE FIXED INDEX      | X$KCCFE (ind:1)  |    20 |   260 |     0   (0)|          |
    |  28 |     VIEW                              |                  |     5 |   150 |    11  (19)| 00:00:01 |
    |  29 |      HASH GROUP BY                    |                  |     5 |   105 |    11  (19)| 00:00:01 |
    |  30 |       VIEW                            | DBA_FREE_SPACE   |    79 |  1659 |    10  (10)| 00:00:01 |
    |  31 |        UNION-ALL                      |                  |       |       |            |          |
    |  32 |         NESTED LOOPS                  |                  |     1 |    64 |     1   (0)| 00:00:01 |
    |  33 |          NESTED LOOPS                 |                  |     1 |    45 |     1   (0)| 00:00:01 |
    |  34 |           INDEX FULL SCAN             | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |* 35 |           TABLE ACCESS CLUSTER        | FET$             |     1 |    39 |     0   (0)|          |
    |* 36 |            INDEX UNIQUE SCAN          | I_TS#            |     1 |       |     0   (0)|          |
    |* 37 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    19 |     0   (0)|          |
    |* 38 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)|          |
    |  39 |         NESTED LOOPS                  |                  |    76 |  5320 |     4   (0)| 00:00:01 |
    |  40 |          NESTED LOOPS                 |                  |    76 |  4864 |     4   (0)| 00:00:01 |
    |* 41 |           TABLE ACCESS FULL           | TS$              |     5 |   125 |     4   (0)| 00:00:01 |
    |* 42 |           FIXED TABLE FIXED INDEX     | X$KTFBFE (ind:1) |    17 |   663 |     0   (0)|          |
    |* 43 |          INDEX UNIQUE SCAN            | I_FILE2          |     1 |     6 |     0   (0)|          |
    |  44 |         NESTED LOOPS                  |                  |     1 |   135 |     2  (50)| 00:00:01 |
    |  45 |          NESTED LOOPS                 |                  |     1 |    70 |     1   (0)| 00:00:01 |
    |  46 |           NESTED LOOPS                |                  |     1 |    45 |     1   (0)| 00:00:01 |
    |  47 |            INDEX FULL SCAN            | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |  48 |            TABLE ACCESS BY INDEX ROWID| RECYCLEBIN$      |     1 |    39 |     0   (0)|          |
    |* 49 |             INDEX RANGE SCAN          | RECYCLEBIN$_TS   |     1 |       |     0   (0)|          |
    |* 50 |           TABLE ACCESS CLUSTER        | TS$              |     1 |    25 |     0   (0)|          |
    |* 51 |            INDEX UNIQUE SCAN          | I_TS#            |     1 |       |     0   (0)|          |
    |* 52 |          FIXED TABLE FIXED INDEX      | X$KTFBUE (ind:1) |     1 |    65 |     1 (100)| 00:00:01 |
    |  53 |         NESTED LOOPS                  |                  |     1 |   116 |     3   (0)| 00:00:01 |
    |  54 |          NESTED LOOPS                 |                  |     1 |    97 |     3   (0)| 00:00:01 |
    |  55 |           MERGE JOIN CARTESIAN        |                  |     1 |    45 |     3   (0)| 00:00:01 |
    |  56 |            TABLE ACCESS FULL          | RECYCLEBIN$      |     1 |    39 |     2   (0)| 00:00:01 |
    |  57 |            BUFFER SORT                |                  |     5 |    30 |     1   (0)| 00:00:01 |
    |  58 |             INDEX FULL SCAN           | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |  59 |           TABLE ACCESS CLUSTER        | UET$             |     1 |    52 |     0   (0)|          |
    |* 60 |            INDEX UNIQUE SCAN          | I_FILE#_BLOCK#   |     1 |       |     0   (0)|          |
    |* 61 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    19 |     0   (0)|          |
    |* 62 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)|          |
    |  63 |    NESTED LOOPS OUTER                 |                  |     1 |    58 |     3  (34)| 00:00:01 |
    |  64 |     VIEW                              |                  |     1 |    30 |     2  (50)| 00:00:01 |
    |  65 |      HASH GROUP BY                    |                  |     1 |   416 |     2  (50)| 00:00:01 |
    |  66 |       NESTED LOOPS                    |                  |     1 |   416 |     1   (0)| 00:00:01 |
    |  67 |        NESTED LOOPS                   |                  |     1 |   364 |     1   (0)| 00:00:01 |
    |  68 |         NESTED LOOPS                  |                  |     1 |   349 |     0   (0)|          |
    |* 69 |          FIXED TABLE FULL             | X$KCCFN          |     1 |   297 |     0   (0)|          |
    |* 70 |          FIXED TABLE FIXED INDEX      | X$KTFTHC (ind:1) |     1 |    52 |     0   (0)|          |
    |  71 |         TABLE ACCESS CLUSTER          | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 72 |          INDEX UNIQUE SCAN            | I_TS#            |     1 |       |     0   (0)|          |
    |* 73 |        FIXED TABLE FIXED INDEX        | X$KCCTF (ind:1)  |     1 |    52 |     0   (0)|          |
    |  74 |     VIEW PUSHED PREDICATE             |                  |     1 |    28 |     1   (0)| 00:00:01 |
    |  75 |      SORT GROUP BY                    |                  |     1 |    90 |     1   (0)| 00:00:01 |
    |  76 |       NESTED LOOPS                    |                  |     1 |    90 |     1   (0)| 00:00:01 |
    |* 77 |        TABLE ACCESS BY INDEX ROWID    | TS$              |     1 |    25 |     1   (0)| 00:00:01 |
    |* 78 |         INDEX UNIQUE SCAN             | I_TS1            |     1 |       |     0   (0)|          |
    |* 79 |        FIXED TABLE FIXED INDEX        | X$KTFTHC (ind:2) |     1 |    65 |     0   (0)|          |
    ----------------------------------------------------------------------------------------------------------
    
    Query Block Name / Object Alias (identified by operation id):
    -------------------------------------------------------------
    
       1 - SET$1
       3 - SEL$1
       4 - SEL$2        / D@SEL$1
       5 - SEL$2
       6 - SET$2        / DBA_DATA_FILES@SEL$2
       7 - SET$2
       8 - SEL$C8360722
      11 - SEL$C8360722 / X$KCCFN@SEL$5
      12 - SEL$C8360722 / F@SEL$3
      13 - SEL$C8360722 / F@SEL$3
      14 - SEL$C8360722 / FE@SEL$3
      15 - SEL$C8360722 / TS@SEL$3
      16 - SEL$C8360722 / TS@SEL$3
      17 - SEL$A731BD80
      21 - SEL$A731BD80 / X$KCCFN@SEL$8
      22 - SEL$A731BD80 / HC@SEL$6
      23 - SEL$A731BD80 / TS@SEL$6
      24 - SEL$A731BD80 / TS@SEL$6
      25 - SEL$A731BD80 / F@SEL$6
      26 - SEL$A731BD80 / F@SEL$6
      27 - SEL$A731BD80 / FE@SEL$6
      28 - SEL$9        / F@SEL$1
      29 - SEL$9
      30 - SET$3        / DBA_FREE_SPACE@SEL$9
      31 - SET$3
      32 - SEL$10
      34 - SEL$10       / FI@SEL$10
      35 - SEL$10       / F@SEL$10
      36 - SEL$10       / F@SEL$10
      37 - SEL$10       / TS@SEL$10
      38 - SEL$10       / TS@SEL$10
      39 - SEL$11
      41 - SEL$11       / TS@SEL$11
      42 - SEL$11       / F@SEL$11
      43 - SEL$11       / FI@SEL$11
      44 - SEL$12
      47 - SEL$12       / FI@SEL$12
      48 - SEL$12       / RB@SEL$12
      49 - SEL$12       / RB@SEL$12
      50 - SEL$12       / TS@SEL$12
      51 - SEL$12       / TS@SEL$12
      52 - SEL$12       / U@SEL$12
      53 - SEL$13
      56 - SEL$13       / RB@SEL$13
      58 - SEL$13       / FI@SEL$13
      59 - SEL$13       / U@SEL$13
      60 - SEL$13       / U@SEL$13
      61 - SEL$13       / TS@SEL$13
      62 - SEL$13       / TS@SEL$13
      63 - SEL$14
      64 - SEL$29F99543 / D@SEL$14
      65 - SEL$29F99543
      69 - SEL$29F99543 / V@SEL$16
      70 - SEL$29F99543 / HC@SEL$16
      71 - SEL$29F99543 / TS@SEL$16
      72 - SEL$29F99543 / TS@SEL$16
      73 - SEL$29F99543 / TF@SEL$16
      74 - SEL$ADB656C7 / F@SEL$14
      75 - SEL$ADB656C7
      77 - SEL$ADB656C7 / TS@SEL$19
      78 - SEL$ADB656C7 / TS@SEL$19
      79 - SEL$ADB656C7 / HC@SEL$19
    
    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$C8360722")
          MERGE(@"SEL$7286615E")
          OUTLINE_LEAF(@"SEL$A731BD80")
          MERGE(@"SEL$8A3193DA")
          OUTLINE_LEAF(@"SET$2")
          OUTLINE_LEAF(@"SEL$2")
          OUTLINE_LEAF(@"SEL$10")
          OUTLINE_LEAF(@"SEL$11")
          OUTLINE_LEAF(@"SEL$12")
          OUTLINE_LEAF(@"SEL$13")
          OUTLINE_LEAF(@"SET$3")
          OUTLINE_LEAF(@"SEL$9")
          OUTLINE_LEAF(@"SEL$1")
          OUTLINE_LEAF(@"SEL$29F99543")
          MERGE(@"SEL$16")
          OUTLINE_LEAF(@"SEL$ADB656C7")
          PUSH_PRED(@"SEL$14" "F"@"SEL$14" 1)
          OUTLINE_LEAF(@"SEL$14")
          OUTLINE_LEAF(@"SET$1")
          OUTLINE(@"SEL$3")
          OUTLINE(@"SEL$7286615E")
          MERGE(@"SEL$5")
          OUTLINE(@"SEL$6")
          OUTLINE(@"SEL$8A3193DA")
          MERGE(@"SEL$8")
          OUTLINE(@"SEL$15")
          OUTLINE(@"SEL$16")
          OUTLINE(@"SEL$E9CE8D49")
          MERGE(@"SEL$07C48A2D")
          OUTLINE(@"SEL$14")
          OUTLINE(@"SEL$4")
          OUTLINE(@"SEL$5")
          OUTLINE(@"SEL$7")
          OUTLINE(@"SEL$8")
          OUTLINE(@"SEL$17")
          OUTLINE(@"SEL$07C48A2D")
          MERGE(@"SEL$19")
          OUTLINE(@"SEL$18")
          OUTLINE(@"SEL$19")
          NO_ACCESS(@"SEL$14" "D"@"SEL$14")
          NO_ACCESS(@"SEL$14" "F"@"SEL$14")
          LEADING(@"SEL$14" "D"@"SEL$14" "F"@"SEL$14")
          USE_NL(@"SEL$14" "F"@"SEL$14")
          NO_ACCESS(@"SEL$1" "D"@"SEL$1")
          NO_ACCESS(@"SEL$1" "F"@"SEL$1")
          LEADING(@"SEL$1" "D"@"SEL$1" "F"@"SEL$1")
          USE_HASH(@"SEL$1" "F"@"SEL$1")
          NO_ACCESS(@"SEL$2" "DBA_DATA_FILES"@"SEL$2")
          USE_HASH_AGGREGATION(@"SEL$2")
          NO_ACCESS(@"SEL$9" "DBA_FREE_SPACE"@"SEL$9")
          USE_HASH_AGGREGATION(@"SEL$9")
          FULL(@"SEL$13" "RB"@"SEL$13")
          INDEX(@"SEL$13" "FI"@"SEL$13" ("FILE$"."TS#" "FILE$"."RELFILE#"))
          INDEX(@"SEL$13" "U"@"SEL$13" "I_FILE#_BLOCK#")
          INDEX(@"SEL$13" "TS"@"SEL$13" "I_TS#")
          LEADING(@"SEL$13" "RB"@"SEL$13" "FI"@"SEL$13" "U"@"SEL$13" "TS"@"SEL$13")
          USE_MERGE_CARTESIAN(@"SEL$13" "FI"@"SEL$13")
          USE_NL(@"SEL$13" "U"@"SEL$13")
          USE_NL(@"SEL$13" "TS"@"SEL$13")
          INDEX(@"SEL$12" "FI"@"SEL$12" ("FILE$"."TS#" "FILE$"."RELFILE#"))
          INDEX_RS_ASC(@"SEL$12" "RB"@"SEL$12" ("RECYCLEBIN$"."TS#"))
          INDEX(@"SEL$12" "TS"@"SEL$12" "I_TS#")
          FULL(@"SEL$12" "U"@"SEL$12")
          LEADING(@"SEL$12" "FI"@"SEL$12" "RB"@"SEL$12" "TS"@"SEL$12" "U"@"SEL$12")
          USE_NL(@"SEL$12" "RB"@"SEL$12")
          USE_NL(@"SEL$12" "TS"@"SEL$12")
          USE_NL(@"SEL$12" "U"@"SEL$12")
          FULL(@"SEL$11" "TS"@"SEL$11")
          FULL(@"SEL$11" "F"@"SEL$11")
          INDEX(@"SEL$11" "FI"@"SEL$11" ("FILE$"."TS#" "FILE$"."RELFILE#"))
          LEADING(@"SEL$11" "TS"@"SEL$11" "F"@"SEL$11" "FI"@"SEL$11")
          USE_NL(@"SEL$11" "F"@"SEL$11")
          USE_NL(@"SEL$11" "FI"@"SEL$11")
          INDEX(@"SEL$10" "FI"@"SEL$10" ("FILE$"."TS#" "FILE$"."RELFILE#"))
          INDEX(@"SEL$10" "F"@"SEL$10" "I_TS#")
          INDEX(@"SEL$10" "TS"@"SEL$10" "I_TS#")
          LEADING(@"SEL$10" "FI"@"SEL$10" "F"@"SEL$10" "TS"@"SEL$10")
          USE_NL(@"SEL$10" "F"@"SEL$10")
          USE_NL(@"SEL$10" "TS"@"SEL$10")
          FULL(@"SEL$A731BD80" "X$KCCFN"@"SEL$8")
          FULL(@"SEL$A731BD80" "HC"@"SEL$6")
          INDEX(@"SEL$A731BD80" "TS"@"SEL$6" "I_TS#")
          INDEX_RS_ASC(@"SEL$A731BD80" "F"@"SEL$6" ("FILE$"."FILE#"))
          FULL(@"SEL$A731BD80" "FE"@"SEL$6")
          LEADING(@"SEL$A731BD80" "X$KCCFN"@"SEL$8" "HC"@"SEL$6" "TS"@"SEL$6" "F"@"SEL$6" "FE"@"SEL$6")
          USE_NL(@"SEL$A731BD80" "HC"@"SEL$6")
          USE_NL(@"SEL$A731BD80" "TS"@"SEL$6")
          USE_NL(@"SEL$A731BD80" "F"@"SEL$6")
          USE_NL(@"SEL$A731BD80" "FE"@"SEL$6")
          FULL(@"SEL$C8360722" "X$KCCFN"@"SEL$5")
          INDEX_RS_ASC(@"SEL$C8360722" "F"@"SEL$3" ("FILE$"."FILE#"))
          FULL(@"SEL$C8360722" "FE"@"SEL$3")
          INDEX(@"SEL$C8360722" "TS"@"SEL$3" "I_TS#")
          LEADING(@"SEL$C8360722" "X$KCCFN"@"SEL$5" "F"@"SEL$3" "FE"@"SEL$3" "TS"@"SEL$3")
          USE_NL(@"SEL$C8360722" "F"@"SEL$3")
          USE_NL(@"SEL$C8360722" "FE"@"SEL$3")
          USE_NL(@"SEL$C8360722" "TS"@"SEL$3")
          FULL(@"SEL$29F99543" "V"@"SEL$16")
          FULL(@"SEL$29F99543" "HC"@"SEL$16")
          INDEX(@"SEL$29F99543" "TS"@"SEL$16" "I_TS#")
          FULL(@"SEL$29F99543" "TF"@"SEL$16")
          LEADING(@"SEL$29F99543" "V"@"SEL$16" "HC"@"SEL$16" "TS"@"SEL$16" "TF"@"SEL$16")
          USE_NL(@"SEL$29F99543" "HC"@"SEL$16")
          USE_NL(@"SEL$29F99543" "TS"@"SEL$16")
          USE_NL(@"SEL$29F99543" "TF"@"SEL$16")
          USE_HASH_AGGREGATION(@"SEL$29F99543")
          INDEX_RS_ASC(@"SEL$ADB656C7" "TS"@"SEL$19" ("TS$"."NAME"))
          FULL(@"SEL$ADB656C7" "HC"@"SEL$19")
          LEADING(@"SEL$ADB656C7" "TS"@"SEL$19" "HC"@"SEL$19")
          USE_NL(@"SEL$ADB656C7" "HC"@"SEL$19")
          END_OUTLINE_DATA
      */
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("D"."TABLESPACE_NAME"="F"."TABLESPACE_NAME")
      11 - filter(("FNNAM" IS NOT NULL AND "FNTYP"=4 AND "INST_ID"=USERENV('INSTANCE') AND
                  BITAND("FNFLG",4)<>4))
      12 - filter("F"."SPARE1" IS NULL)
      13 - access("FNFNO"="F"."FILE#")
      14 - filter("FE"."FENUM"="F"."FILE#")
      16 - access("F"."TS#"="TS"."TS#")
      21 - filter(("FNNAM" IS NOT NULL AND "FNTYP"=4 AND "INST_ID"=USERENV('INSTANCE') AND
                  BITAND("FNFLG",4)<>4))
      22 - filter("FNFNO"="HC"."KTFBHCAFNO")
      24 - access("HC"."KTFBHCTSN"="TS"."TS#")
      25 - filter("F"."SPARE1" IS NOT NULL)
      26 - access("FNFNO"="F"."FILE#")
      27 - filter("FE"."FENUM"="F"."FILE#")
      35 - filter("F"."FILE#"="FI"."RELFILE#")
      36 - access("F"."TS#"="FI"."TS#")
      37 - filter("TS"."BITMAPPED"=0)
      38 - access("TS"."TS#"="F"."TS#")
      41 - filter(("TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0 AND INTERNAL_FUNCTION("TS"."ONLINE$")))
      42 - filter("TS"."TS#"="F"."KTFBFETSN")
      43 - access("F"."KTFBFETSN"="FI"."TS#" AND "F"."KTFBFEFNO"="FI"."RELFILE#")
      49 - access("RB"."TS#"="FI"."TS#")
      50 - filter(("TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0 AND INTERNAL_FUNCTION("TS"."ONLINE$")))
      51 - access("TS"."TS#"="RB"."TS#")
      52 - filter(("U"."KTFBUEFNO"="FI"."RELFILE#" AND "U"."KTFBUESEGTSN"="RB"."TS#" AND
                  "U"."KTFBUESEGFNO"="RB"."FILE#" AND "U"."KTFBUESEGBNO"="RB"."BLOCK#"))
      60 - access("U"."TS#"="RB"."TS#" AND "U"."SEGFILE#"="RB"."FILE#" AND
                  "U"."SEGBLOCK#"="RB"."BLOCK#")
           filter(("U"."TS#"="FI"."TS#" AND "U"."SEGFILE#"="FI"."RELFILE#"))
      61 - filter("TS"."BITMAPPED"=0)
      62 - access("TS"."TS#"="U"."TS#")
      69 - filter(("V"."FNNAM" IS NOT NULL AND "V"."FNTYP"=7))
      70 - filter("V"."FNFNO"="HC"."KTFTHCTFNO")
      72 - access("HC"."KTFTHCTSN"="TS"."TS#")
      73 - filter(("TF"."TFDUP"<>0 AND BITAND("TF"."TFSTA",32)<>32 AND "V"."FNFNO"="TF"."TFNUM" AND
                  "TF"."TFFNH"="V"."FNNUM"))
      77 - filter(("TS"."CONTENTS$"=1 AND "TS"."BITMAPPED"<>0 AND "TS"."ONLINE$"=1))
      78 - access("TS"."NAME"="D"."TABLESPACE_NAME")
      79 - filter(("HC"."KTFTHCCVAL"=0 AND "HC"."INST_ID"=USERENV('INSTANCE') AND
                  "TS"."TS#"="HC"."KTFTHCTSN"))
    
    Column Projection Information (identified by operation id):
    -----------------------------------------------------------
    
       1 - (#keys=1) STRDEF[22], STRDEF[30], STRDEF[22], STRDEF[22], STRDEF[22]
       2 - STRDEF[30], STRDEF[22], STRDEF[22], STRDEF[22], STRDEF[22]
       3 - (#keys=1) "D"."TABLESPACE_NAME"[VARCHAR2,30], "SPACE"[NUMBER,22], "FREE_SPACE"[NUMBER,22]
       4 - "D"."TABLESPACE_NAME"[VARCHAR2,30], "SPACE"[NUMBER,22]
       5 - "TABLESPACE_NAME"[VARCHAR2,30], SUM("BLOCKS")[22], SUM("BYTES")[22]
       6 - "TABLESPACE_NAME"[VARCHAR2,30], "BYTES"[NUMBER,22], "BLOCKS"[NUMBER,22]
       7 - STRDEF[30], STRDEF[22], STRDEF[22]
       8 - "F"."BLOCKS"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
       9 - "F"."BLOCKS"[NUMBER,22], "F"."TS#"[NUMBER,22]
      10 - "F"."FILE#"[NUMBER,22], "F"."BLOCKS"[NUMBER,22], "F"."TS#"[NUMBER,22]
      11 - "INST_ID"[NUMBER,22], "FNTYP"[NUMBER,22], "FNFNO"[NUMBER,22], "FNFLG"[NUMBER,22],
           "FNNAM"[VARCHAR2,513]
      12 - "F"."FILE#"[NUMBER,22], "F"."BLOCKS"[NUMBER,22], "F"."TS#"[NUMBER,22]
      13 - "F".ROWID[ROWID,10], "F"."FILE#"[NUMBER,22]
      14 - "FE"."FENUM"[NUMBER,22]
      15 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22]
      16 - "TS".ROWID[ROWID,10]
      17 - "HC"."KTFBHCSZ"[NUMBER,22], "HC"."KTFBHCCVAL"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22]
      18 - "HC"."KTFBHCSZ"[NUMBER,22], "HC"."KTFBHCCVAL"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22], "F"."FILE#"[NUMBER,22]
      19 - "FNFNO"[NUMBER,22], "HC"."KTFBHCSZ"[NUMBER,22], "HC"."KTFBHCCVAL"[NUMBER,22],
           "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      20 - "FNFNO"[NUMBER,22], "HC"."KTFBHCTSN"[NUMBER,22], "HC"."KTFBHCSZ"[NUMBER,22],
           "HC"."KTFBHCCVAL"[NUMBER,22]
      21 - "INST_ID"[NUMBER,22], "FNTYP"[NUMBER,22], "FNFNO"[NUMBER,22], "FNFLG"[NUMBER,22],
           "FNNAM"[VARCHAR2,513]
      22 - "HC"."KTFBHCAFNO"[NUMBER,22], "HC"."KTFBHCTSN"[NUMBER,22], "HC"."KTFBHCSZ"[NUMBER,22],
           "HC"."KTFBHCCVAL"[NUMBER,22]
      23 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22]
      24 - "TS".ROWID[ROWID,10]
      25 - "F"."FILE#"[NUMBER,22]
      26 - "F".ROWID[ROWID,10], "F"."FILE#"[NUMBER,22]
      27 - "FE"."FENUM"[NUMBER,22]
      28 - "F"."TABLESPACE_NAME"[VARCHAR2,30], "FREE_SPACE"[NUMBER,22]
      29 - "TABLESPACE_NAME"[VARCHAR2,30], SUM("BYTES")[22]
      30 - "TABLESPACE_NAME"[VARCHAR2,30], "BYTES"[NUMBER,22]
      31 - STRDEF[30], STRDEF[22]
      32 - "F"."LENGTH"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      33 - "F"."TS#"[NUMBER,22], "F"."LENGTH"[NUMBER,22]
      34 - "FI"."TS#"[NUMBER,22], "FI"."RELFILE#"[NUMBER,22]
      35 - "F".ROWID[ROWID,10], "F"."TS#"[NUMBER,22], "F"."FILE#"[NUMBER,22], "F"."LENGTH"[NUMBER,22]
      36 - "F".ROWID[ROWID,10]
      37 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22], "TS"."BITMAPPED"[NUMBER,22]
      38 - "TS".ROWID[ROWID,10]
      39 - "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22], "F"."KTFBFEBLKS"[NUMBER,22]
      40 - "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22], "F"."KTFBFETSN"[NUMBER,22],
           "F"."KTFBFEFNO"[NUMBER,22], "F"."KTFBFEBLKS"[NUMBER,22]
      41 - "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      42 - "F"."KTFBFETSN"[NUMBER,22], "F"."KTFBFEFNO"[NUMBER,22], "F"."KTFBFEBLKS"[NUMBER,22]
      44 - "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22], "U"."KTFBUEBLKS"[NUMBER,22]
      45 - "FI"."RELFILE#"[NUMBER,22], "RB"."TS#"[NUMBER,22], "RB"."FILE#"[NUMBER,22],
           "RB"."BLOCK#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      46 - "FI"."RELFILE#"[NUMBER,22], "RB"."TS#"[NUMBER,22], "RB"."FILE#"[NUMBER,22],
           "RB"."BLOCK#"[NUMBER,22]
      47 - "FI"."TS#"[NUMBER,22], "FI"."RELFILE#"[NUMBER,22]
      48 - "RB"."TS#"[NUMBER,22], "RB"."FILE#"[NUMBER,22], "RB"."BLOCK#"[NUMBER,22]
      49 - "RB".ROWID[ROWID,10], "RB"."TS#"[NUMBER,22]
      50 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."ONLINE$"[NUMBER,22], "TS"."CONTENTS$"[NUMBER,22], "TS"."BLOCKSIZE"[NUMBER,22],
           "TS"."BITMAPPED"[NUMBER,22]
      51 - "TS".ROWID[ROWID,10]
      52 - "U"."KTFBUESEGTSN"[NUMBER,22], "U"."KTFBUESEGFNO"[NUMBER,22],
           "U"."KTFBUESEGBNO"[NUMBER,22], "U"."KTFBUEFNO"[NUMBER,22], "U"."KTFBUEBLKS"[NUMBER,22]
      53 - "U"."LENGTH"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      54 - "U"."TS#"[NUMBER,22], "U"."LENGTH"[NUMBER,22]
      55 - "RB"."TS#"[NUMBER,22], "RB"."FILE#"[NUMBER,22], "RB"."BLOCK#"[NUMBER,22],
           "FI"."TS#"[NUMBER,22], "FI"."RELFILE#"[NUMBER,22]
      56 - "RB"."TS#"[NUMBER,22], "RB"."FILE#"[NUMBER,22], "RB"."BLOCK#"[NUMBER,22]
      57 - (#keys=0) "FI"."TS#"[NUMBER,22], "FI"."RELFILE#"[NUMBER,22]
      58 - "FI"."TS#"[NUMBER,22], "FI"."RELFILE#"[NUMBER,22]
      59 - "U".ROWID[ROWID,10], "U"."TS#"[NUMBER,22], "U"."SEGFILE#"[NUMBER,22],
           "U"."SEGBLOCK#"[NUMBER,22], "U"."LENGTH"[NUMBER,22]
      60 - "U".ROWID[ROWID,10]
      61 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22], "TS"."BITMAPPED"[NUMBER,22]
      62 - "TS".ROWID[ROWID,10]
      63 - "D"."TABLESPACE_NAME"[VARCHAR2,30], "SPACE"[NUMBER,22], "USED_SPACE"[NUMBER,22],
           "FREE_SPACE"[NUMBER,22]
      64 - "D"."TABLESPACE_NAME"[VARCHAR2,30], "SPACE"[NUMBER,22]
      65 - "TS"."NAME"[VARCHAR2,30], SUM(DECODE("HC"."KTFTHCCVAL",0,"HC"."KTFTHCSZ",NULL))[22],
           SUM(DECODE("HC"."KTFTHCCVAL",0,"TS"."BLOCKSIZE"*"HC"."KTFTHCSZ",NULL))[22]
      66 - "HC"."KTFTHCSZ"[NUMBER,22], "HC"."KTFTHCCVAL"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22]
      67 - "V"."FNNUM"[NUMBER,22], "V"."FNFNO"[NUMBER,22], "HC"."KTFTHCSZ"[NUMBER,22],
           "HC"."KTFTHCCVAL"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      68 - "V"."FNNUM"[NUMBER,22], "V"."FNFNO"[NUMBER,22], "HC"."KTFTHCTSN"[NUMBER,22],
           "HC"."KTFTHCSZ"[NUMBER,22], "HC"."KTFTHCCVAL"[NUMBER,22]
      69 - "V"."FNNUM"[NUMBER,22], "V"."FNTYP"[NUMBER,22], "V"."FNFNO"[NUMBER,22],
           "V"."FNNAM"[VARCHAR2,513]
      70 - "HC"."KTFTHCTFNO"[NUMBER,22], "HC"."KTFTHCTSN"[NUMBER,22], "HC"."KTFTHCSZ"[NUMBER,22],
           "HC"."KTFTHCCVAL"[NUMBER,22]
      71 - "TS".ROWID[ROWID,10], "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30],
           "TS"."BLOCKSIZE"[NUMBER,22]
      72 - "TS".ROWID[ROWID,10]
      73 - "TF"."TFNUM"[NUMBER,22], "TF"."TFSTA"[NUMBER,22], "TF"."TFFNH"[NUMBER,22],
           "TF"."TFDUP"[NUMBER,22]
      74 - "USED_SPACE"[NUMBER,22], "FREE_SPACE"[NUMBER,22]
      75 - (#keys=1) "TS"."NAME"[VARCHAR2,30], SUM("HC"."KTFTHCFREE"*"TS"."BLOCKSIZE")[22],
           SUM(("HC"."KTFTHCSZ"-"HC"."KTFTHCFREE")*"TS"."BLOCKSIZE")[22]
      76 - "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22], "HC"."KTFTHCSZ"[NUMBER,22],
           "HC"."KTFTHCFREE"[NUMBER,22]
      77 - "TS"."TS#"[NUMBER,22], "TS"."NAME"[VARCHAR2,30], "TS"."BLOCKSIZE"[NUMBER,22]
      78 - "TS".ROWID[ROWID,10], "TS"."NAME"[VARCHAR2,30]
      79 - "HC"."INST_ID"[NUMBER,22], "HC"."KTFTHCTSN"[NUMBER,22], "HC"."KTFTHCSZ"[NUMBER,22],
           "HC"."KTFTHCFREE"[NUMBER,22], "HC"."KTFTHCCVAL"[NUMBER,22]
    
    
    450 rows selected.
    

    针对运行计划比較长的sql语句,第一眼看有没有明显的问题。如TABLE ACCESS FULL、MERGE JOIN CARTESIAN等,这些会给sql带来较差的性能问题。

    一眼看去,全是系统基表,不敢乱动。

    那么在运行计划56行那块,有个全表扫描,最要命的是上面另一个笛卡尔积。以下来看看recyclebin$表中有多少行记录:

    SQL> select count(1) from RECYCLEBIN$;
    
      COUNT(1)
    ----------
        697111
    接近70万行记录,难怪1小时也跑不出来。


    清除recyclebin:

    SQL> purge dba_recyclebin;
    
    DBA Recyclebin purged.
    
    SQL> select count(1) from recyclebin$;
    
      COUNT(1)
    ----------
          3334
        

    再次执行sql:

    SQL> set timing on;
    SQL>            set linesize 200;
    SQL>            set pagesize 1000;
    SQL>            col tablespace_name for a20;
    SQL>            col Total(M)  for 999,999,999;
    SQL>            col USED(M) for 999,999,999;
    SQL>            col FREE(M) for 999,999,999;
    SQL>            SELECT D.TABLESPACE_NAME,
      2                    SPACE "Total(M)",
      3                    SPACE - NVL(FREE_SPACE, 0) "USED(M)",
      4                    ROUND((1 - NVL(FREE_SPACE, 0) / SPACE) * 100, 2) "USED(%)",
      5                    FREE_SPACE "FREE(M)"
      6               FROM (SELECT TABLESPACE_NAME,
      7                            ROUND(SUM(BYTES) / (1024 * 1024), 2) SPACE,
      8                            SUM(BLOCKS) BLOCKS
      9                       FROM DBA_DATA_FILES
     10                      GROUP BY TABLESPACE_NAME) D,
     11                    (SELECT TABLESPACE_NAME,
     12                            ROUND(SUM(BYTES) / (1024 * 1024), 2) FREE_SPACE
     13                       FROM DBA_FREE_SPACE
     14                      GROUP BY TABLESPACE_NAME) F
     15              WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
     16             UNION ALL --if have tempfile
     17             SELECT D.TABLESPACE_NAME,
     18                    SPACE "Total(M)",
     19                    USED_SPACE "USED(M)",
     20                    ROUND(NVL(USED_SPACE, 0) / SPACE * 100, 2) "USED(%)",
     21                    NVL(FREE_SPACE, 0) "FREE(M)"
     22               FROM (SELECT TABLESPACE_NAME,
     23                            ROUND(SUM(BYTES) / (1024 * 1024), 2) SPACE,
     24                            SUM(BLOCKS) BLOCKS
     25                       FROM DBA_TEMP_FILES
     26                      GROUP BY TABLESPACE_NAME) D,
     27                    (SELECT TABLESPACE_NAME,
     28                            ROUND(SUM(BYTES_USED) / (1024 * 1024), 2) USED_SPACE,
     29                            ROUND(SUM(BYTES_FREE) / (1024 * 1024), 2) FREE_SPACE
     30                       FROM V$TEMP_SPACE_HEADER
     31                      GROUP BY TABLESPACE_NAME) F
     32              WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
     33              ORDER BY 4;
    
    20 rows selected.
    
    Elapsed: 00:00:04.17
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3967328987
    
    ----------------------------------------------------------------------------------------------------------
    | Id  | Operation                             | Name             | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                      |                  |     3 |   178 |    20  (25)| 00:00:01 |
    |   1 |  SORT ORDER BY                        |                  |     3 |   178 |    19  (22)| 00:00:01 |
    |   2 |   UNION-ALL                           |                  |       |       |            |          |
    |*  3 |    HASH JOIN OUTER                    |                  |     2 |   120 |    16  (19)| 00:00:01 |
    |   4 |     VIEW                              |                  |     2 |    60 |     5  (20)| 00:00:01 |
    |   5 |      HASH GROUP BY                    |                  |     2 |    68 |     5  (20)| 00:00:01 |
    |   6 |       VIEW                            | DBA_DATA_FILES   |     2 |    68 |     4   (0)| 00:00:01 |
    |   7 |        UNION-ALL                      |                  |       |       |            |          |
    |   8 |         NESTED LOOPS                  |                  |     1 |   356 |     2   (0)| 00:00:01 |
    |   9 |          NESTED LOOPS                 |                  |     1 |   341 |     1   (0)| 00:00:01 |
    |  10 |           NESTED LOOPS                |                  |     1 |   328 |     1   (0)| 00:00:01 |
    |* 11 |            FIXED TABLE FULL           | X$KCCFN          |     1 |   310 |     0   (0)| 00:00:01 |
    |* 12 |            TABLE ACCESS BY INDEX ROWID| FILE$            |     1 |    18 |     1   (0)| 00:00:01 |
    |* 13 |             INDEX UNIQUE SCAN         | I_FILE1          |     1 |       |     0   (0)| 00:00:01 |
    |* 14 |           FIXED TABLE FIXED INDEX     | X$KCCFE (ind:1)  |    20 |   260 |     0   (0)| 00:00:01 |
    |  15 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 16 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |  17 |         NESTED LOOPS                  |                  |     1 |   399 |     2   (0)| 00:00:01 |
    |  18 |          NESTED LOOPS                 |                  |     1 |   386 |     2   (0)| 00:00:01 |
    |  19 |           NESTED LOOPS                |                  |     1 |   377 |     1   (0)| 00:00:01 |
    |  20 |            NESTED LOOPS               |                  |     1 |   362 |     0   (0)| 00:00:01 |
    |* 21 |             FIXED TABLE FULL          | X$KCCFN          |     1 |   310 |     0   (0)| 00:00:01 |
    |* 22 |             FIXED TABLE FIXED INDEX   | X$KTFBHC (ind:1) |     1 |    52 |     0   (0)| 00:00:01 |
    |  23 |            TABLE ACCESS CLUSTER       | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 24 |             INDEX UNIQUE SCAN         | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |* 25 |           TABLE ACCESS BY INDEX ROWID | FILE$            |     1 |     9 |     1   (0)| 00:00:01 |
    |* 26 |            INDEX UNIQUE SCAN          | I_FILE1          |     1 |       |     0   (0)| 00:00:01 |
    |* 27 |          FIXED TABLE FIXED INDEX      | X$KCCFE (ind:1)  |    20 |   260 |     0   (0)| 00:00:01 |
    |  28 |     VIEW                              |                  |     5 |   150 |    11  (19)| 00:00:01 |
    |  29 |      HASH GROUP BY                    |                  |     5 |   105 |    11  (19)| 00:00:01 |
    |  30 |       VIEW                            | DBA_FREE_SPACE   |    79 |  1659 |    10  (10)| 00:00:01 |
    |  31 |        UNION-ALL                      |                  |       |       |            |          |
    |  32 |         NESTED LOOPS                  |                  |     1 |    64 |     1   (0)| 00:00:01 |
    |  33 |          NESTED LOOPS                 |                  |     1 |    45 |     1   (0)| 00:00:01 |
    |  34 |           INDEX FULL SCAN             | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |* 35 |           TABLE ACCESS CLUSTER        | FET$             |     1 |    39 |     0   (0)| 00:00:01 |
    |* 36 |            INDEX UNIQUE SCAN          | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |* 37 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    19 |     0   (0)| 00:00:01 |
    |* 38 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |  39 |         NESTED LOOPS                  |                  |    76 |  5320 |     4   (0)| 00:00:01 |
    |  40 |          NESTED LOOPS                 |                  |    76 |  4864 |     4   (0)| 00:00:01 |
    |* 41 |           TABLE ACCESS FULL           | TS$              |     5 |   125 |     4   (0)| 00:00:01 |
    |* 42 |           FIXED TABLE FIXED INDEX     | X$KTFBFE (ind:1) |    17 |   663 |     0   (0)| 00:00:01 |
    |* 43 |          INDEX UNIQUE SCAN            | I_FILE2          |     1 |     6 |     0   (0)| 00:00:01 |
    |  44 |         NESTED LOOPS                  |                  |     1 |   135 |     2  (50)| 00:00:01 |
    |  45 |          NESTED LOOPS                 |                  |     1 |    70 |     1   (0)| 00:00:01 |
    |  46 |           NESTED LOOPS                |                  |     1 |    45 |     1   (0)| 00:00:01 |
    |  47 |            INDEX FULL SCAN            | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |  48 |            TABLE ACCESS BY INDEX ROWID| RECYCLEBIN$      |     1 |    39 |     0   (0)| 00:00:01 |
    |* 49 |             INDEX RANGE SCAN          | RECYCLEBIN$_TS   |     1 |       |     0   (0)| 00:00:01 |
    |* 50 |           TABLE ACCESS CLUSTER        | TS$              |     1 |    25 |     0   (0)| 00:00:01 |
    |* 51 |            INDEX UNIQUE SCAN          | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |* 52 |          FIXED TABLE FIXED INDEX      | X$KTFBUE (ind:1) |     1 |    65 |     1 (100)| 00:00:01 |
    |  53 |         NESTED LOOPS                  |                  |     1 |   116 |     3   (0)| 00:00:01 |
    |  54 |          NESTED LOOPS                 |                  |     1 |    97 |     3   (0)| 00:00:01 |
    |  55 |           MERGE JOIN CARTESIAN        |                  |     1 |    45 |     3   (0)| 00:00:01 |
    |  56 |            TABLE ACCESS FULL          | RECYCLEBIN$      |     1 |    39 |     2   (0)| 00:00:01 |
    |  57 |            BUFFER SORT                |                  |     5 |    30 |     1   (0)| 00:00:01 |
    |  58 |             INDEX FULL SCAN           | I_FILE2          |     5 |    30 |     1   (0)| 00:00:01 |
    |  59 |           TABLE ACCESS CLUSTER        | UET$             |     1 |    52 |     0   (0)| 00:00:01 |
    |* 60 |            INDEX UNIQUE SCAN          | I_FILE#_BLOCK#   |     1 |       |     0   (0)| 00:00:01 |
    |* 61 |          TABLE ACCESS CLUSTER         | TS$              |     1 |    19 |     0   (0)| 00:00:01 |
    |* 62 |           INDEX UNIQUE SCAN           | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |  63 |    NESTED LOOPS OUTER                 |                  |     1 |    58 |     3  (34)| 00:00:01 |
    |  64 |     VIEW                              |                  |     1 |    30 |     2  (50)| 00:00:01 |
    |  65 |      HASH GROUP BY                    |                  |     1 |   416 |     2  (50)| 00:00:01 |
    |  66 |       NESTED LOOPS                    |                  |     1 |   416 |     1   (0)| 00:00:01 |
    |  67 |        NESTED LOOPS                   |                  |     1 |   364 |     1   (0)| 00:00:01 |
    |  68 |         NESTED LOOPS                  |                  |     1 |   349 |     0   (0)| 00:00:01 |
    |* 69 |          FIXED TABLE FULL             | X$KCCFN          |     1 |   297 |     0   (0)| 00:00:01 |
    |* 70 |          FIXED TABLE FIXED INDEX      | X$KTFTHC (ind:1) |     1 |    52 |     0   (0)| 00:00:01 |
    |  71 |         TABLE ACCESS CLUSTER          | TS$              |     1 |    15 |     1   (0)| 00:00:01 |
    |* 72 |          INDEX UNIQUE SCAN            | I_TS#            |     1 |       |     0   (0)| 00:00:01 |
    |* 73 |        FIXED TABLE FIXED INDEX        | X$KCCTF (ind:1)  |     1 |    52 |     0   (0)| 00:00:01 |
    |  74 |     VIEW PUSHED PREDICATE             |                  |     1 |    28 |     1   (0)| 00:00:01 |
    |  75 |      SORT GROUP BY                    |                  |     1 |    90 |     1   (0)| 00:00:01 |
    |  76 |       NESTED LOOPS                    |                  |     1 |    90 |     1   (0)| 00:00:01 |
    |* 77 |        TABLE ACCESS BY INDEX ROWID    | TS$              |     1 |    25 |     1   (0)| 00:00:01 |
    |* 78 |         INDEX UNIQUE SCAN             | I_TS1            |     1 |       |     0   (0)| 00:00:01 |
    |* 79 |        FIXED TABLE FIXED INDEX        | X$KTFTHC (ind:2) |     1 |    65 |     0   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("D"."TABLESPACE_NAME"="F"."TABLESPACE_NAME"(+))
      11 - filter("FNNAM" IS NOT NULL AND "FNTYP"=4 AND "INST_ID"=USERENV('INSTANCE') AND
                  BITAND("FNFLG",4)<>4)
      12 - filter("F"."SPARE1" IS NULL)
      13 - access("FNFNO"="F"."FILE#")
      14 - filter("FE"."FENUM"="F"."FILE#")
      16 - access("F"."TS#"="TS"."TS#")
      21 - filter("FNNAM" IS NOT NULL AND "FNTYP"=4 AND "INST_ID"=USERENV('INSTANCE') AND
                  BITAND("FNFLG",4)<>4)
      22 - filter("FNFNO"="HC"."KTFBHCAFNO")
      24 - access("HC"."KTFBHCTSN"="TS"."TS#")
      25 - filter("F"."SPARE1" IS NOT NULL)
      26 - access("FNFNO"="F"."FILE#")
      27 - filter("FE"."FENUM"="F"."FILE#")
      35 - filter("F"."FILE#"="FI"."RELFILE#")
      36 - access("F"."TS#"="FI"."TS#")
      37 - filter("TS"."BITMAPPED"=0)
      38 - access("TS"."TS#"="F"."TS#")
      41 - filter("TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0 AND ("TS"."ONLINE$"=1 OR
                  "TS"."ONLINE$"=4))
      42 - filter("TS"."TS#"="F"."KTFBFETSN")
      43 - access("F"."KTFBFETSN"="FI"."TS#" AND "F"."KTFBFEFNO"="FI"."RELFILE#")
      49 - access("RB"."TS#"="FI"."TS#")
      50 - filter("TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0 AND ("TS"."ONLINE$"=1 OR
                  "TS"."ONLINE$"=4))
      51 - access("TS"."TS#"="RB"."TS#")
      52 - filter("U"."KTFBUEFNO"="FI"."RELFILE#" AND "U"."KTFBUESEGTSN"="RB"."TS#" AND
                  "U"."KTFBUESEGFNO"="RB"."FILE#" AND "U"."KTFBUESEGBNO"="RB"."BLOCK#")
      60 - access("U"."TS#"="RB"."TS#" AND "U"."SEGFILE#"="RB"."FILE#" AND
                  "U"."SEGBLOCK#"="RB"."BLOCK#")
           filter("U"."TS#"="FI"."TS#" AND "U"."SEGFILE#"="FI"."RELFILE#")
      61 - filter("TS"."BITMAPPED"=0)
      62 - access("TS"."TS#"="U"."TS#")
      69 - filter("V"."FNNAM" IS NOT NULL AND "V"."FNTYP"=7)
      70 - filter("V"."FNFNO"="HC"."KTFTHCTFNO")
      72 - access("HC"."KTFTHCTSN"="TS"."TS#")
      73 - filter("TF"."TFDUP"<>0 AND BITAND("TF"."TFSTA",32)<>32 AND "V"."FNFNO"="TF"."TFNUM" AND
                  "TF"."TFFNH"="V"."FNNUM")
      77 - filter("TS"."CONTENTS$"=1 AND "TS"."BITMAPPED"<>0 AND "TS"."ONLINE$"=1)
      78 - access("TS"."NAME"="D"."TABLESPACE_NAME")
      79 - filter("HC"."KTFTHCCVAL"=0 AND "HC"."INST_ID"=USERENV('INSTANCE') AND
                  "TS"."TS#"="HC"."KTFTHCTSN")
    
    
    Statistics
    ----------------------------------------------------------
           3472  recursive calls
           2445  db block gets
          25284  consistent gets
           3282  physical reads
              0  redo size
           1675  bytes sent via SQL*Net to client
            535  bytes received via SQL*Net from client
              3  SQL*Net roundtrips to/from client
              5  sorts (memory)
              0  sorts (disk)
             20  rows processed
    
    SQL> 

    这个时候sql仅仅须要4秒就能出结果了。从业务那块了解到,他们每天会批量导入和删除表。那么问题就明了了。

    定时清理recyclebin还是很重要的。


  • 相关阅读:
    循环逗号分割数组!
    只是想好好学习一下!
    html元素水平垂直居中
    闭包知识点--笔记
    20160314
    从零开始做运维-零
    Nginx 和 CodeIgniter
    安装PIL库
    init
    NutUI3 多端实践之路
  • 原文地址:https://www.cnblogs.com/mfmdaoyou/p/6883239.html
Copyright © 2020-2023  润新知