Oracle查询dba_extents视图很慢

 

Oracle查询dba_extents视图很慢

 

问题描述

下边这条SQL查询每次大概要花1分钟左右,实在是比较异常。

select owner,tablespace_name from dba_extents where segment_name='AUD$' group by owner,tablespace_name;

 

测试分析

先实际跑完一遍,去详细的执行信息。

模板复制:

set pagesize 9999 long 9999 line 500
alter session set statistics_level=all;
select owner,tablespace_name from dba_extents where segment_name='AUD$' group by owner,tablespace_name;
select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));

 

执行时间如下:

20:25:06 SYS@anonymous> set pagesize 9999 long 9999 line 500
20:25:15 SYS@anonymous> alter session set statistics_level=all;

Session altered.

Elapsed: 00:00:00.00
20:26:33 SYS@anonymous> select owner,tablespace_name from dba_extents where segment_name='AUD$' group by owner,tablespace_name;

OWNER                          TABLESPACE_NAME
------------------------------ ------------------------------
SYS                            SYSTEM

Elapsed: 00:01:01.87

 

获取执行计划:

20:27:48 SYS@anonymous> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  dggb0d96bj8dy, child number 4
-------------------------------------
select owner,tablespace_name from dba_extents where segment_name='AUD$'
group by owner,tablespace_name

Plan hash value: 1482657742

------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                              | Name                | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                       |                     |      1 |        |      1 |00:01:01.87 |     190K|   7157 |       |       |          |
|   1 |  HASH GROUP BY                         |                     |      1 |    543K|      1 |00:01:01.87 |     190K|   7157 |  2331K|  2194K|  435K (0)|
|   2 |   VIEW                                 | DBA_EXTENTS         |      1 |    543K|    259 |00:01:01.87 |     190K|   7157 |       |       |          |
|   3 |    UNION-ALL                           |                     |      1 |        |    259 |00:01:01.87 |     190K|   7157 |       |       |          |
|   4 |     NESTED LOOPS                       |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
|   5 |      NESTED LOOPS                      |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
|   6 |       TABLE ACCESS FULL                | UET$                |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
|*  7 |       INDEX UNIQUE SCAN                | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|   8 |      VIEW                              | SYS_DBA_SEGS        |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|   9 |       UNION ALL PUSHED PREDICATE       |                     |      0 |        |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  10 |        NESTED LOOPS                    |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  11 |         NESTED LOOPS OUTER             |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  12 |          MERGE JOIN CARTESIAN          |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  13 |           NESTED LOOPS                 |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  14 |            NESTED LOOPS                |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 15 |             INDEX UNIQUE SCAN          | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  16 |             TABLE ACCESS CLUSTER       | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 17 |              INDEX UNIQUE SCAN         | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 18 |            TABLE ACCESS CLUSTER        | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 19 |             INDEX UNIQUE SCAN          | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  20 |           BUFFER SORT                  |                     |      0 |      2 |      0 |00:00:00.01 |       0 |      0 | 73728 | 73728 |          |
|* 21 |            INDEX SKIP SCAN             | I_OBJ2              |      0 |      2 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  22 |          TABLE ACCESS CLUSTER          | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 23 |           INDEX UNIQUE SCAN            | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 24 |         VIEW                           | SYS_OBJECTS         |      0 |      5 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  25 |          UNION ALL PUSHED PREDICATE    |                     |      0 |        |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 26 |           TABLE ACCESS CLUSTER         | TAB$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 27 |            INDEX UNIQUE SCAN           | I_OBJ#              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 28 |           TABLE ACCESS BY INDEX ROWID  | TABPART$            |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 29 |            INDEX UNIQUE SCAN           | I_TABPART_OBJ$      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 30 |           TABLE ACCESS CLUSTER         | CLU$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 31 |            INDEX UNIQUE SCAN           | I_OBJ#              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 32 |           TABLE ACCESS BY INDEX ROWID  | IND$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 33 |            INDEX UNIQUE SCAN           | I_IND1              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 34 |           TABLE ACCESS BY INDEX ROWID  | INDPART$            |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 35 |            INDEX UNIQUE SCAN           | I_INDPART_OBJ$      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 36 |           TABLE ACCESS BY INDEX ROWID  | LOB$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 37 |            INDEX UNIQUE SCAN           | I_LOB2              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 38 |           TABLE ACCESS BY INDEX ROWID  | TABSUBPART$         |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 39 |            INDEX UNIQUE SCAN           | I_TABSUBPART$_OBJ$  |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 40 |           TABLE ACCESS BY INDEX ROWID  | INDSUBPART$         |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 41 |            INDEX UNIQUE SCAN           | I_INDSUBPART_OBJ$   |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 42 |           TABLE ACCESS BY INDEX ROWID  | LOBFRAG$            |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 43 |            INDEX UNIQUE SCAN           | I_LOBFRAG$_FRAGOBJ$ |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  44 |        NESTED LOOPS                    |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  45 |         NESTED LOOPS                   |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  46 |          NESTED LOOPS OUTER            |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  47 |           NESTED LOOPS                 |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  48 |            NESTED LOOPS                |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 49 |             INDEX UNIQUE SCAN          | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  50 |             TABLE ACCESS CLUSTER       | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 51 |              INDEX UNIQUE SCAN         | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 52 |            TABLE ACCESS CLUSTER        | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 53 |             INDEX UNIQUE SCAN          | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  54 |           TABLE ACCESS CLUSTER         | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 55 |            INDEX UNIQUE SCAN           | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 56 |          INDEX RANGE SCAN              | I_UNDO2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 57 |         TABLE ACCESS BY INDEX ROWID    | UNDO$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  58 |        NESTED LOOPS OUTER              |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  59 |         NESTED LOOPS                   |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  60 |          NESTED LOOPS                  |                     |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  61 |           TABLE ACCESS BY INDEX ROWID  | FILE$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 62 |            INDEX UNIQUE SCAN           | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  63 |           TABLE ACCESS CLUSTER         | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 64 |            INDEX UNIQUE SCAN           | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 65 |          TABLE ACCESS CLUSTER          | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 66 |           INDEX UNIQUE SCAN            | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  67 |         TABLE ACCESS CLUSTER           | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 68 |          INDEX UNIQUE SCAN             | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 69 |     HASH JOIN                          |                     |      1 |    543K|    259 |00:01:01.87 |     190K|   7157 |  1214K|  1214K|  709K (0)|
|* 70 |      HASH JOIN                         |                     |      1 |  20549 |      1 |00:00:00.33 |     138K|      0 |  1969K|  1969K| 1531K (0)|
|  71 |       INDEX FULL SCAN                  | I_FILE2             |      1 |    106 |    108 |00:00:00.01 |       1 |      0 |       |       |          |
|  72 |       VIEW                             | SYS_DBA_SEGS        |      1 |   6785 |      1 |00:00:00.33 |     138K|      0 |       |       |          |
|  73 |        UNION-ALL                       |                     |      1 |        |      1 |00:00:00.33 |     138K|      0 |       |       |          |
|  74 |         NESTED LOOPS                   |                     |      1 |   6783 |      1 |00:00:00.32 |     137K|      0 |       |       |          |
|  75 |          NESTED LOOPS OUTER            |                     |      1 |      2 |  10578 |00:00:00.10 |   21543 |      0 |       |       |          |
|  76 |           MERGE JOIN CARTESIAN         |                     |      1 |      2 |  10578 |00:00:00.07 |   10961 |      0 |       |       |          |
|  77 |            NESTED LOOPS                |                     |      1 |      1 |  10578 |00:00:00.06 |   10896 |      0 |       |       |          |
|  78 |             NESTED LOOPS               |                     |      1 |      1 |  10578 |00:00:00.03 |     314 |      0 |       |       |          |
|* 79 |              TABLE ACCESS FULL         | SEG$                |      1 |      1 |  10578 |00:00:00.02 |     310 |      0 |       |       |          |
|* 80 |              INDEX UNIQUE SCAN         | I_FILE2             |  10578 |      1 |  10578 |00:00:00.01 |       4 |      0 |       |       |          |
|  81 |             TABLE ACCESS CLUSTER       | TS$                 |  10578 |      1 |  10578 |00:00:00.02 |   10582 |      0 |       |       |          |
|* 82 |              INDEX UNIQUE SCAN         | I_TS#               |  10578 |      1 |  10578 |00:00:00.01 |       4 |      0 |       |       |          |
|  83 |            BUFFER SORT                 |                     |  10578 |      2 |  10578 |00:00:00.01 |      65 |      0 |  2048 |  2048 | 2048  (0)|
|* 84 |             INDEX SKIP SCAN            | I_OBJ2              |      1 |      2 |      1 |00:00:00.01 |      65 |      0 |       |       |          |
|  85 |           TABLE ACCESS CLUSTER         | USER$               |  10578 |      1 |  10578 |00:00:00.02 |   10582 |      0 |       |       |          |
|* 86 |            INDEX UNIQUE SCAN           | I_USER#             |  10578 |      1 |  10578 |00:00:00.01 |       4 |      0 |       |       |          |
|* 87 |          VIEW                          | SYS_OBJECTS         |  10578 |      2 |      1 |00:00:00.22 |     116K|      0 |       |       |          |
|  88 |           UNION ALL PUSHED PREDICATE   |                     |  10578 |        |  10578 |00:00:00.21 |     116K|      0 |       |       |          |
|* 89 |            TABLE ACCESS CLUSTER        | TAB$                |  10578 |      1 |  10578 |00:00:00.03 |   21161 |      0 |       |       |          |
|* 90 |             INDEX UNIQUE SCAN          | I_OBJ#              |  10578 |      1 |  10578 |00:00:00.01 |   10583 |      0 |       |       |          |
|  91 |            TABLE ACCESS BY INDEX ROWID | TABPART$            |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
|* 92 |             INDEX UNIQUE SCAN          | I_TABPART_OBJ$      |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
|  93 |            TABLE ACCESS CLUSTER        | CLU$                |  10578 |      1 |      0 |00:00:00.02 |   21161 |      0 |       |       |          |
|* 94 |             INDEX UNIQUE SCAN          | I_OBJ#              |  10578 |      1 |  10578 |00:00:00.01 |   10583 |      0 |       |       |          |
|* 95 |            TABLE ACCESS BY INDEX ROWID | IND$                |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
|* 96 |             INDEX UNIQUE SCAN          | I_IND1              |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
|  97 |            TABLE ACCESS BY INDEX ROWID | INDPART$            |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
|* 98 |             INDEX UNIQUE SCAN          | I_INDPART_OBJ$      |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
|* 99 |            TABLE ACCESS BY INDEX ROWID | LOB$                |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
|*100 |             INDEX UNIQUE SCAN          | I_LOB2              |  10578 |      1 |      0 |00:00:00.01 |   10583 |      0 |       |       |          |
| 101 |            TABLE ACCESS BY INDEX ROWID | TABSUBPART$         |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
|*102 |             INDEX UNIQUE SCAN          | I_TABSUBPART$_OBJ$  |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
| 103 |            TABLE ACCESS BY INDEX ROWID | INDSUBPART$         |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
|*104 |             INDEX UNIQUE SCAN          | I_INDSUBPART_OBJ$   |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
| 105 |            TABLE ACCESS BY INDEX ROWID | LOBFRAG$            |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
|*106 |             INDEX UNIQUE SCAN          | I_LOBFRAG$_FRAGOBJ$ |  10578 |      1 |      0 |00:00:00.01 |   10578 |      0 |       |       |          |
| 107 |         NESTED LOOPS OUTER             |                     |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
| 108 |          NESTED LOOPS                  |                     |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
| 109 |           NESTED LOOPS                 |                     |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
| 110 |            NESTED LOOPS                |                     |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
|*111 |             TABLE ACCESS BY INDEX ROWID| UNDO$               |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
|*112 |              INDEX RANGE SCAN          | I_UNDO2             |      1 |      1 |      0 |00:00:00.01 |       2 |      0 |       |       |          |
|*113 |             INDEX UNIQUE SCAN          | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*114 |            TABLE ACCESS CLUSTER        | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*115 |             INDEX UNIQUE SCAN          | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
| 116 |           TABLE ACCESS CLUSTER         | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*117 |            INDEX UNIQUE SCAN           | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
| 118 |          TABLE ACCESS CLUSTER          | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*119 |           INDEX UNIQUE SCAN            | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
| 120 |         NESTED LOOPS                   |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
| 121 |          NESTED LOOPS                  |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
| 122 |           NESTED LOOPS OUTER           |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
| 123 |            NESTED LOOPS                |                     |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
|*124 |             TABLE ACCESS FULL          | SEG$                |      1 |      1 |      0 |00:00:00.01 |     310 |      0 |       |       |          |
| 125 |             TABLE ACCESS CLUSTER       | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*126 |              INDEX UNIQUE SCAN         | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
| 127 |            TABLE ACCESS CLUSTER        | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*128 |             INDEX UNIQUE SCAN          | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*129 |           INDEX UNIQUE SCAN            | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|*130 |          TABLE ACCESS BY INDEX ROWID   | FILE$               |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
| 131 |      FIXED TABLE FULL                  | X$KTFBUE            |      1 |    100K|    723K|00:01:01.20 |   52350 |   7157 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------------

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

   7 - access("E"."TS#"="F"."TS#" AND "E"."FILE#"="F"."RELFILE#")
  15 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  17 - access("TS"."TS#"="E"."TS#")
  18 - filter((BITAND(NVL("S"."SPARE1",0),1)=0 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
  19 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter(("S"."TS#"="TS"."TS#" AND "S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#"))
  21 - access("O"."NAME"='AUD$')
       filter("O"."NAME"='AUD$')
  23 - access("O"."OWNER#"="U"."USER#")
  24 - filter(("S"."FILE#"="SO"."HEADER_FILE" AND "S"."BLOCK#"="SO"."HEADER_BLOCK" AND "S"."TS#"="SO"."TS_NUMBER" AND
              "S"."TYPE#"="SO"."SEGMENT_TYPE_ID" AND "O"."TYPE#"="SO"."OBJECT_TYPE_ID"))
  26 - filter(("T"."BLOCK#"="E"."SEGBLOCK#" AND "T"."FILE#"="E"."SEGFILE#" AND "T"."TS#"="E"."TS#" AND BITAND("T"."PROPERTY",1024)=0))
  27 - access("T"."OBJ#"="O"."OBJ#")
  28 - filter(("TP"."BLOCK#"="E"."SEGBLOCK#" AND "TP"."FILE#"="E"."SEGFILE#" AND "TP"."TS#"="E"."TS#"))
  29 - access("TP"."OBJ#"="O"."OBJ#")
  30 - filter(("C"."BLOCK#"="E"."SEGBLOCK#" AND "C"."FILE#"="E"."SEGFILE#" AND "C"."TS#"="E"."TS#"))
  31 - access("C"."OBJ#"="O"."OBJ#")
  32 - filter(("I"."BLOCK#"="E"."SEGBLOCK#" AND "I"."FILE#"="E"."SEGFILE#" AND "I"."TS#"="E"."TS#" AND INTERNAL_FUNCTION("I"."TYPE#")))
  33 - access("I"."OBJ#"="O"."OBJ#")
  34 - filter(("IP"."BLOCK#"="E"."SEGBLOCK#" AND "IP"."FILE#"="E"."SEGFILE#" AND "IP"."TS#"="E"."TS#"))
  35 - access("IP"."OBJ#"="O"."OBJ#")
  36 - filter(("L"."BLOCK#"="E"."SEGBLOCK#" AND "L"."FILE#"="E"."SEGFILE#" AND "L"."TS#"="E"."TS#" AND (BITAND("L"."PROPERTY",64)=0 OR
              BITAND("L"."PROPERTY",128)=128)))
  37 - access("L"."LOBJ#"="O"."OBJ#")
  38 - filter(("TSP"."BLOCK#"="E"."SEGBLOCK#" AND "TSP"."FILE#"="E"."SEGFILE#" AND "TSP"."TS#"="E"."TS#"))
  39 - access("TSP"."OBJ#"="O"."OBJ#")
  40 - filter(("ISP"."FILE#"="E"."SEGFILE#" AND "ISP"."BLOCK#"="E"."SEGBLOCK#" AND "ISP"."TS#"="E"."TS#"))
  41 - access("ISP"."OBJ#"="O"."OBJ#")
  42 - filter(("LF"."BLOCK#"="E"."SEGBLOCK#" AND "LF"."FILE#"="E"."SEGFILE#" AND "LF"."TS#"="E"."TS#"))
  43 - access("LF"."FRAGOBJ#"="O"."OBJ#")
  49 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  51 - access("TS"."TS#"="E"."TS#")
  52 - filter((INTERNAL_FUNCTION("S"."TYPE#") AND BITAND(NVL("S"."SPARE1",0),1)=0 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
  53 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter("S"."TS#"="TS"."TS#")
  55 - access("S"."USER#"="U"."USER#")
  56 - access("UN"."NAME"='AUD$')
  57 - filter(("UN"."BLOCK#"="E"."SEGBLOCK#" AND "UN"."FILE#"="E"."SEGFILE#" AND "UN"."TS#"="E"."TS#" AND "UN"."STATUS$"<>1 AND
              "S"."FILE#"="UN"."FILE#" AND "S"."BLOCK#"="UN"."BLOCK#" AND "S"."TS#"="UN"."TS#" AND "UN"."TS#"="F"."TS#" AND "UN"."FILE#"="F"."RELFILE#"))
  62 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  64 - access("TS"."TS#"="E"."TS#")
  65 - filter(("S"."TYPE#"<>6 AND "S"."TYPE#"<>5 AND "S"."TYPE#"<>8 AND BITAND(NVL("S"."SPARE1",0),1)=0 AND BITAND(NVL("S"."SPARE1",0),65536)=0 AND
              "S"."TYPE#"<>10 AND "S"."TYPE#"<>1))
  66 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter(("S"."TS#"="TS"."TS#" AND "S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#" AND
              TO_CHAR("F"."FILE#")||'.'||TO_CHAR("S"."BLOCK#")='AUD$'))
  68 - access("S"."USER#"="U"."USER#")
  69 - access("E"."KTFBUESEGFNO"="DS"."RELATIVE_FNO" AND "E"."KTFBUESEGBNO"="DS"."HEADER_BLOCK" AND "E"."KTFBUESEGTSN"="DS"."TABLESPACE_ID" AND
              "E"."KTFBUEFNO"="F"."RELFILE#")
  70 - access("DS"."TABLESPACE_ID"="F"."TS#")
  79 - filter((BITAND(NVL("S"."SPARE1",0),1)=1 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
  80 - access("S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#")
  82 - access("S"."TS#"="TS"."TS#")
  84 - access("O"."NAME"='AUD$')
       filter("O"."NAME"='AUD$')
  86 - access("O"."OWNER#"="U"."USER#")
  87 - filter(("S"."FILE#"="SO"."HEADER_FILE" AND "S"."BLOCK#"="SO"."HEADER_BLOCK" AND "S"."TS#"="SO"."TS_NUMBER" AND
              "S"."TYPE#"="SO"."SEGMENT_TYPE_ID" AND "O"."TYPE#"="SO"."OBJECT_TYPE_ID"))
  89 - filter(BITAND("T"."PROPERTY",1024)=0)
  90 - access("T"."OBJ#"="O"."OBJ#")
  92 - access("TP"."OBJ#"="O"."OBJ#")
  94 - access("C"."OBJ#"="O"."OBJ#")
  95 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=8 OR
              "I"."TYPE#"=9))
  96 - access("I"."OBJ#"="O"."OBJ#")
  98 - access("IP"."OBJ#"="O"."OBJ#")
  99 - filter((BITAND("L"."PROPERTY",64)=0 OR BITAND("L"."PROPERTY",128)=128))
 100 - access("L"."LOBJ#"="O"."OBJ#")
 102 - access("TSP"."OBJ#"="O"."OBJ#")
 104 - access("ISP"."OBJ#"="O"."OBJ#")
 106 - access("LF"."FRAGOBJ#"="O"."OBJ#")
 111 - filter("UN"."STATUS$"<>1)
 112 - access("UN"."NAME"='AUD$')
 113 - access("UN"."TS#"="F"."TS#" AND "UN"."FILE#"="F"."RELFILE#")
 114 - filter((INTERNAL_FUNCTION("S"."TYPE#") AND BITAND(NVL("S"."SPARE1",0),1)=1 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
 115 - access("S"."TS#"="UN"."TS#" AND "S"."FILE#"="UN"."FILE#" AND "S"."BLOCK#"="UN"."BLOCK#")
 117 - access("S"."TS#"="TS"."TS#")
 119 - access("S"."USER#"="U"."USER#")
 124 - filter(("S"."TYPE#"<>6 AND "S"."TYPE#"<>5 AND "S"."TYPE#"<>8 AND BITAND(NVL("S"."SPARE1",0),1)=1 AND BITAND(NVL("S"."SPARE1",0),65536)=0 AND
              "S"."TYPE#"<>10 AND "S"."TYPE#"<>1))
 126 - access("S"."TS#"="TS"."TS#")
 128 - access("S"."USER#"="U"."USER#")
 129 - access("S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#")
 130 - filter(TO_CHAR("F"."FILE#")||'.'||TO_CHAR("S"."BLOCK#")='AUD$')


232 rows selected.

Elapsed: 00:00:00.10

 

直接看id=131的那一行,时间都花在对固定表X$KTFBUE的全表扫描上,这个算是Oracle的一个BUG,当该固定表没有统计信息的时候,Oracle不会对他做动态采样,而是直接使用基数为100000的行。

 

查看索引的信息,固定表的索引有点奇怪:

SYS@zkm1> select * from V$INDEXED_FIXED_COLUMN where table_name='X$KTFBUE';

TABLE_NAME                     INDEX_NUMBER COLUMN_NAME                    COLUMN_POSITION
------------------------------ ------------ ------------------------------ ---------------
X$KTFBUE                                  1 KTFBUESEGBNO                                 2
X$KTFBUE                                  1 KTFBUESEGFNO                                 1
X$KTFBUE                                  1 KTFBUESEGTSN                                 0

 

看不出啥。 

 

百度或者mos上都可以查找到相关的原因和办法。

mos参考文档:Query Against DBA_EXTENTS Performs Slowly After Upgrade to 11.2.0.3 (Doc ID 1453425.1)

这篇文章有提供几种方法。

Gathering stats on the X$KTFBUE table using the following command:
EXEC DBMS_STATS.GATHER_TABLE_STATS('SYS', 'X$KTFBUE');

For more information on gathering fixed table statistics see:
Document 798257.1 GATHER_FIXED_OBJECTS_STATS Considerations

OR
alter session set "_optimizer_cartesian_enabled" = false;

OR
alter session set "_smm_auto_cost_enabled" = false;

OR
Disable fix for unpublished Bug Bug 11814428: POOR CARDINALITY ESTIMATE FROM JOIN WITH A UNION-ALL VIEW:
alter session set "_FIX_CONTROL" = "11814428:0";

 

不过只有收集统计信息和最下边的BUG修复关掉才有效。

收集统计信息这个方法略过,因为还有一个表空间查询缓慢的问题和这个是一样的问题。

 我们采用另外一种方法,关闭11814428的修复,执行:

20:30:19 SYS@anonymous> alter session set "_FIX_CONTROL" = "11814428:0";

Session altered.

Elapsed: 00:00:00.00

 

之后再次运行变快了:

20:30:21 SYS@anonymous> select owner,tablespace_name from dba_extents where segment_name='AUD$' group by owner,tablespace_name;

OWNER                          TABLESPACE_NAME
------------------------------ ------------------------------
SYS                            SYSTEM

Elapsed: 00:00:00.33

 

可以发现执行计划对X$KTFBUE已经采用了索引:

20:30:28 SYS@anonymous> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  dggb0d96bj8dy, child number 5
-------------------------------------
select owner,tablespace_name from dba_extents where segment_name='AUD$'
group by owner,tablespace_name

Plan hash value: 381184789

------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                 | Name                | Starts | E-Rows | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                          |                     |      1 |        |      1 |00:00:00.01 |     719 |       |       |          |
|   1 |  HASH GROUP BY                            |                     |      1 |    729 |      1 |00:00:00.01 |     719 |  1646K|  1646K|  497K (0)|
|   2 |   VIEW                                    | DBA_EXTENTS         |      1 |    729 |    259 |00:00:00.01 |     719 |       |       |          |
|   3 |    UNION-ALL                              |                     |      1 |        |    259 |00:00:00.01 |     719 |       |       |          |
|   4 |     NESTED LOOPS                          |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
|   5 |      NESTED LOOPS                         |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
|   6 |       TABLE ACCESS FULL                   | UET$                |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
|*  7 |       INDEX UNIQUE SCAN                   | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|   8 |      VIEW                                 | SYS_DBA_SEGS        |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|   9 |       UNION ALL PUSHED PREDICATE          |                     |      0 |        |      0 |00:00:00.01 |       0 |       |       |          |
|  10 |        NESTED LOOPS                       |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  11 |         NESTED LOOPS OUTER                |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  12 |          MERGE JOIN CARTESIAN             |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  13 |           NESTED LOOPS                    |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  14 |            NESTED LOOPS                   |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 15 |             INDEX UNIQUE SCAN             | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  16 |             TABLE ACCESS CLUSTER          | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 17 |              INDEX UNIQUE SCAN            | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 18 |            TABLE ACCESS CLUSTER           | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 19 |             INDEX UNIQUE SCAN             | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  20 |           BUFFER SORT                     |                     |      0 |      2 |      0 |00:00:00.01 |       0 | 73728 | 73728 |          |
|* 21 |            INDEX SKIP SCAN                | I_OBJ2              |      0 |      2 |      0 |00:00:00.01 |       0 |       |       |          |
|  22 |          TABLE ACCESS CLUSTER             | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 23 |           INDEX UNIQUE SCAN               | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 24 |         VIEW                              | SYS_OBJECTS         |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  25 |          UNION ALL PUSHED PREDICATE       |                     |      0 |        |      0 |00:00:00.01 |       0 |       |       |          |
|* 26 |           TABLE ACCESS CLUSTER            | TAB$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 27 |            INDEX UNIQUE SCAN              | I_OBJ#              |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 28 |           TABLE ACCESS BY INDEX ROWID     | TABPART$            |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 29 |            INDEX UNIQUE SCAN              | I_TABPART_OBJ$      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 30 |           TABLE ACCESS CLUSTER            | CLU$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 31 |            INDEX UNIQUE SCAN              | I_OBJ#              |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 32 |           TABLE ACCESS BY INDEX ROWID     | IND$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 33 |            INDEX UNIQUE SCAN              | I_IND1              |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 34 |           TABLE ACCESS BY INDEX ROWID     | INDPART$            |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 35 |            INDEX UNIQUE SCAN              | I_INDPART_OBJ$      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 36 |           TABLE ACCESS BY INDEX ROWID     | LOB$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 37 |            INDEX UNIQUE SCAN              | I_LOB2              |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 38 |           TABLE ACCESS BY INDEX ROWID     | TABSUBPART$         |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 39 |            INDEX UNIQUE SCAN              | I_TABSUBPART$_OBJ$  |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 40 |           TABLE ACCESS BY INDEX ROWID     | INDSUBPART$         |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 41 |            INDEX UNIQUE SCAN              | I_INDSUBPART_OBJ$   |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 42 |           TABLE ACCESS BY INDEX ROWID     | LOBFRAG$            |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 43 |            INDEX UNIQUE SCAN              | I_LOBFRAG$_FRAGOBJ$ |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  44 |        NESTED LOOPS                       |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  45 |         NESTED LOOPS                      |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  46 |          NESTED LOOPS OUTER               |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  47 |           NESTED LOOPS                    |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  48 |            NESTED LOOPS                   |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 49 |             INDEX UNIQUE SCAN             | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  50 |             TABLE ACCESS CLUSTER          | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 51 |              INDEX UNIQUE SCAN            | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 52 |            TABLE ACCESS CLUSTER           | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 53 |             INDEX UNIQUE SCAN             | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  54 |           TABLE ACCESS CLUSTER            | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 55 |            INDEX UNIQUE SCAN              | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 56 |          INDEX RANGE SCAN                 | I_UNDO2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 57 |         TABLE ACCESS BY INDEX ROWID       | UNDO$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  58 |        NESTED LOOPS OUTER                 |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  59 |         NESTED LOOPS                      |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  60 |          NESTED LOOPS                     |                     |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  61 |           TABLE ACCESS BY INDEX ROWID     | FILE$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 62 |            INDEX UNIQUE SCAN              | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  63 |           TABLE ACCESS CLUSTER            | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 64 |            INDEX UNIQUE SCAN              | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 65 |          TABLE ACCESS CLUSTER             | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 66 |           INDEX UNIQUE SCAN               | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|  67 |         TABLE ACCESS CLUSTER              | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 68 |          INDEX UNIQUE SCAN                | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|* 69 |     HASH JOIN                             |                     |      1 |    728 |    259 |00:00:00.01 |     409 |  1969K|  1969K| 1497K (0)|
|  70 |      INDEX FULL SCAN                      | I_FILE2             |      1 |    106 |    108 |00:00:00.01 |       1 |       |       |          |
|  71 |      NESTED LOOPS                         |                     |      1 |  24769 |    259 |00:00:00.01 |     408 |       |       |          |
|  72 |       VIEW                                | SYS_DBA_SEGS        |      1 |      3 |      1 |00:00:00.01 |     401 |       |       |          |
|  73 |        UNION-ALL                          |                     |      1 |        |      1 |00:00:00.01 |     401 |       |       |          |
|  74 |         NESTED LOOPS                      |                     |      1 |      1 |      1 |00:00:00.01 |      89 |       |       |          |
|  75 |          NESTED LOOPS                     |                     |      1 |      1 |      1 |00:00:00.01 |      87 |       |       |          |
|  76 |           NESTED LOOPS                    |                     |      1 |      1 |      1 |00:00:00.01 |      86 |       |       |          |
|  77 |            NESTED LOOPS OUTER             |                     |      1 |      1 |      1 |00:00:00.01 |      83 |       |       |          |
|  78 |             NESTED LOOPS                  |                     |      1 |      1 |      1 |00:00:00.01 |      81 |       |       |          |
|* 79 |              INDEX SKIP SCAN              | I_OBJ2              |      1 |      2 |      1 |00:00:00.01 |      65 |       |       |          |
|* 80 |              VIEW                         | SYS_OBJECTS         |      1 |      1 |      1 |00:00:00.01 |      16 |       |       |          |
|  81 |               UNION ALL PUSHED PREDICATE  |                     |      1 |        |      1 |00:00:00.01 |      16 |       |       |          |
|* 82 |                TABLE ACCESS CLUSTER       | TAB$                |      1 |      1 |      1 |00:00:00.01 |       3 |       |       |          |
|* 83 |                 INDEX UNIQUE SCAN         | I_OBJ#              |      1 |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|  84 |                TABLE ACCESS BY INDEX ROWID| TABPART$            |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|* 85 |                 INDEX UNIQUE SCAN         | I_TABPART_OBJ$      |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|  86 |                TABLE ACCESS CLUSTER       | CLU$                |      1 |      1 |      0 |00:00:00.01 |       3 |       |       |          |
|* 87 |                 INDEX UNIQUE SCAN         | I_OBJ#              |      1 |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|* 88 |                TABLE ACCESS BY INDEX ROWID| IND$                |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|* 89 |                 INDEX UNIQUE SCAN         | I_IND1              |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|  90 |                TABLE ACCESS BY INDEX ROWID| INDPART$            |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|* 91 |                 INDEX UNIQUE SCAN         | I_INDPART_OBJ$      |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|* 92 |                TABLE ACCESS BY INDEX ROWID| LOB$                |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|* 93 |                 INDEX UNIQUE SCAN         | I_LOB2              |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|  94 |                TABLE ACCESS BY INDEX ROWID| TABSUBPART$         |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|* 95 |                 INDEX UNIQUE SCAN         | I_TABSUBPART$_OBJ$  |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|  96 |                TABLE ACCESS BY INDEX ROWID| INDSUBPART$         |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|* 97 |                 INDEX UNIQUE SCAN         | I_INDSUBPART_OBJ$   |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|  98 |                TABLE ACCESS BY INDEX ROWID| LOBFRAG$            |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
|* 99 |                 INDEX UNIQUE SCAN         | I_LOBFRAG$_FRAGOBJ$ |      1 |      1 |      0 |00:00:00.01 |       1 |       |       |          |
| 100 |             TABLE ACCESS CLUSTER          | USER$               |      1 |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|*101 |              INDEX UNIQUE SCAN            | I_USER#             |      1 |      1 |      1 |00:00:00.01 |       1 |       |       |          |
|*102 |            TABLE ACCESS CLUSTER           | SEG$                |      1 |      1 |      1 |00:00:00.01 |       3 |       |       |          |
|*103 |             INDEX UNIQUE SCAN             | I_FILE#_BLOCK#      |      1 |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|*104 |           INDEX UNIQUE SCAN               | I_FILE2             |      1 |      1 |      1 |00:00:00.01 |       1 |       |       |          |
| 105 |          TABLE ACCESS CLUSTER             | TS$                 |      1 |      1 |      1 |00:00:00.01 |       2 |       |       |          |
|*106 |           INDEX UNIQUE SCAN               | I_TS#               |      1 |      1 |      1 |00:00:00.01 |       1 |       |       |          |
| 107 |         NESTED LOOPS OUTER                |                     |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
| 108 |          NESTED LOOPS                     |                     |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
| 109 |           NESTED LOOPS                    |                     |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
| 110 |            NESTED LOOPS                   |                     |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|*111 |             TABLE ACCESS BY INDEX ROWID   | UNDO$               |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|*112 |              INDEX RANGE SCAN             | I_UNDO2             |      1 |      1 |      0 |00:00:00.01 |       2 |       |       |          |
|*113 |             INDEX UNIQUE SCAN             | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*114 |            TABLE ACCESS CLUSTER           | SEG$                |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*115 |             INDEX UNIQUE SCAN             | I_FILE#_BLOCK#      |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
| 116 |           TABLE ACCESS CLUSTER            | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*117 |            INDEX UNIQUE SCAN              | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
| 118 |          TABLE ACCESS CLUSTER             | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*119 |           INDEX UNIQUE SCAN               | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
| 120 |         NESTED LOOPS                      |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
| 121 |          NESTED LOOPS                     |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
| 122 |           NESTED LOOPS OUTER              |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
| 123 |            NESTED LOOPS                   |                     |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
|*124 |             TABLE ACCESS FULL             | SEG$                |      1 |      1 |      0 |00:00:00.01 |     310 |       |       |          |
| 125 |             TABLE ACCESS CLUSTER          | TS$                 |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*126 |              INDEX UNIQUE SCAN            | I_TS#               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
| 127 |            TABLE ACCESS CLUSTER           | USER$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*128 |             INDEX UNIQUE SCAN             | I_USER#             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*129 |           INDEX UNIQUE SCAN               | I_FILE2             |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*130 |          TABLE ACCESS BY INDEX ROWID      | FILE$               |      0 |      1 |      0 |00:00:00.01 |       0 |       |       |          |
|*131 |       FIXED TABLE FIXED INDEX             | X$KTFBUE (ind:1)    |      1 |   8256 |    259 |00:00:00.01 |       7 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------

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

   7 - access("E"."TS#"="F"."TS#" AND "E"."FILE#"="F"."RELFILE#")
  15 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  17 - access("TS"."TS#"="E"."TS#")
  18 - filter((BITAND(NVL("S"."SPARE1",0),1)=0 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
  19 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter(("S"."TS#"="TS"."TS#" AND "S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#"))
  21 - access("O"."NAME"='AUD$')
       filter("O"."NAME"='AUD$')
  23 - access("O"."OWNER#"="U"."USER#")
  24 - filter(("S"."FILE#"="SO"."HEADER_FILE" AND "S"."BLOCK#"="SO"."HEADER_BLOCK" AND "S"."TS#"="SO"."TS_NUMBER" AND
              "S"."TYPE#"="SO"."SEGMENT_TYPE_ID" AND "O"."TYPE#"="SO"."OBJECT_TYPE_ID"))
  26 - filter(("T"."BLOCK#"="E"."SEGBLOCK#" AND "T"."FILE#"="E"."SEGFILE#" AND "T"."TS#"="E"."TS#" AND BITAND("T"."PROPERTY",1024)=0))
  27 - access("T"."OBJ#"="O"."OBJ#")
  28 - filter(("TP"."BLOCK#"="E"."SEGBLOCK#" AND "TP"."FILE#"="E"."SEGFILE#" AND "TP"."TS#"="E"."TS#"))
  29 - access("TP"."OBJ#"="O"."OBJ#")
  30 - filter(("C"."BLOCK#"="E"."SEGBLOCK#" AND "C"."FILE#"="E"."SEGFILE#" AND "C"."TS#"="E"."TS#"))
  31 - access("C"."OBJ#"="O"."OBJ#")
  32 - filter(("I"."BLOCK#"="E"."SEGBLOCK#" AND "I"."FILE#"="E"."SEGFILE#" AND "I"."TS#"="E"."TS#" AND INTERNAL_FUNCTION("I"."TYPE#")))
  33 - access("I"."OBJ#"="O"."OBJ#")
  34 - filter(("IP"."BLOCK#"="E"."SEGBLOCK#" AND "IP"."FILE#"="E"."SEGFILE#" AND "IP"."TS#"="E"."TS#"))
  35 - access("IP"."OBJ#"="O"."OBJ#")
  36 - filter(("L"."BLOCK#"="E"."SEGBLOCK#" AND "L"."FILE#"="E"."SEGFILE#" AND "L"."TS#"="E"."TS#" AND (BITAND("L"."PROPERTY",64)=0 OR
              BITAND("L"."PROPERTY",128)=128)))
  37 - access("L"."LOBJ#"="O"."OBJ#")
  38 - filter(("TSP"."BLOCK#"="E"."SEGBLOCK#" AND "TSP"."FILE#"="E"."SEGFILE#" AND "TSP"."TS#"="E"."TS#"))
  39 - access("TSP"."OBJ#"="O"."OBJ#")
  40 - filter(("ISP"."FILE#"="E"."SEGFILE#" AND "ISP"."BLOCK#"="E"."SEGBLOCK#" AND "ISP"."TS#"="E"."TS#"))
  41 - access("ISP"."OBJ#"="O"."OBJ#")
  42 - filter(("LF"."BLOCK#"="E"."SEGBLOCK#" AND "LF"."FILE#"="E"."SEGFILE#" AND "LF"."TS#"="E"."TS#"))
  43 - access("LF"."FRAGOBJ#"="O"."OBJ#")
  49 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  51 - access("TS"."TS#"="E"."TS#")
  52 - filter((INTERNAL_FUNCTION("S"."TYPE#") AND BITAND(NVL("S"."SPARE1",0),1)=0 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
  53 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter("S"."TS#"="TS"."TS#")
  55 - access("S"."USER#"="U"."USER#")
  56 - access("UN"."NAME"='AUD$')
  57 - filter(("UN"."BLOCK#"="E"."SEGBLOCK#" AND "UN"."FILE#"="E"."SEGFILE#" AND "UN"."TS#"="E"."TS#" AND "UN"."STATUS$"<>1 AND
              "S"."FILE#"="UN"."FILE#" AND "S"."BLOCK#"="UN"."BLOCK#" AND "S"."TS#"="UN"."TS#" AND "UN"."TS#"="F"."TS#" AND "UN"."FILE#"="F"."RELFILE#"))
  62 - access("F"."TS#"="E"."TS#" AND "F"."RELFILE#"="E"."SEGFILE#")
  64 - access("TS"."TS#"="E"."TS#")
  65 - filter(("S"."TYPE#"<>6 AND "S"."TYPE#"<>5 AND "S"."TYPE#"<>8 AND BITAND(NVL("S"."SPARE1",0),1)=0 AND
              BITAND(NVL("S"."SPARE1",0),65536)=0 AND "S"."TYPE#"<>10 AND "S"."TYPE#"<>1))
  66 - access("S"."TS#"="E"."TS#" AND "S"."FILE#"="E"."SEGFILE#" AND "S"."BLOCK#"="E"."SEGBLOCK#")
       filter(("S"."TS#"="TS"."TS#" AND "S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#" AND
              TO_CHAR("F"."FILE#")||'.'||TO_CHAR("S"."BLOCK#")='AUD$'))
  68 - access("S"."USER#"="U"."USER#")
  69 - access("DS"."TABLESPACE_ID"="F"."TS#" AND "E"."KTFBUEFNO"="F"."RELFILE#")
  79 - access("O"."NAME"='AUD$')
       filter("O"."NAME"='AUD$')
  80 - filter("O"."TYPE#"="SO"."OBJECT_TYPE_ID")
  82 - filter(BITAND("T"."PROPERTY",1024)=0)
  83 - access("T"."OBJ#"="O"."OBJ#")
  85 - access("TP"."OBJ#"="O"."OBJ#")
  87 - access("C"."OBJ#"="O"."OBJ#")
  88 - filter(("I"."TYPE#"=1 OR "I"."TYPE#"=2 OR "I"."TYPE#"=3 OR "I"."TYPE#"=4 OR "I"."TYPE#"=6 OR "I"."TYPE#"=7 OR "I"."TYPE#"=8 OR
              "I"."TYPE#"=9))
  89 - access("I"."OBJ#"="O"."OBJ#")
  91 - access("IP"."OBJ#"="O"."OBJ#")
  92 - filter((BITAND("L"."PROPERTY",64)=0 OR BITAND("L"."PROPERTY",128)=128))
  93 - access("L"."LOBJ#"="O"."OBJ#")
  95 - access("TSP"."OBJ#"="O"."OBJ#")
  97 - access("ISP"."OBJ#"="O"."OBJ#")
  99 - access("LF"."FRAGOBJ#"="O"."OBJ#")
 101 - access("O"."OWNER#"="U"."USER#")
 102 - filter((BITAND(NVL("S"."SPARE1",0),1)=1 AND BITAND(NVL("S"."SPARE1",0),65536)=0 AND "S"."TYPE#"="SO"."SEGMENT_TYPE_ID"))
 103 - access("S"."TS#"="SO"."TS_NUMBER" AND "S"."FILE#"="SO"."HEADER_FILE" AND "S"."BLOCK#"="SO"."HEADER_BLOCK")
 104 - access("S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#")
 106 - access("S"."TS#"="TS"."TS#")
 111 - filter("UN"."STATUS$"<>1)
 112 - access("UN"."NAME"='AUD$')
 113 - access("UN"."TS#"="F"."TS#" AND "UN"."FILE#"="F"."RELFILE#")
 114 - filter((INTERNAL_FUNCTION("S"."TYPE#") AND BITAND(NVL("S"."SPARE1",0),1)=1 AND BITAND(NVL("S"."SPARE1",0),65536)=0))
 115 - access("S"."TS#"="UN"."TS#" AND "S"."FILE#"="UN"."FILE#" AND "S"."BLOCK#"="UN"."BLOCK#")
 117 - access("S"."TS#"="TS"."TS#")
 119 - access("S"."USER#"="U"."USER#")
 124 - filter(("S"."TYPE#"<>6 AND "S"."TYPE#"<>5 AND "S"."TYPE#"<>8 AND BITAND(NVL("S"."SPARE1",0),1)=1 AND
              BITAND(NVL("S"."SPARE1",0),65536)=0 AND "S"."TYPE#"<>10 AND "S"."TYPE#"<>1))
 126 - access("S"."TS#"="TS"."TS#")
 128 - access("S"."USER#"="U"."USER#")
 129 - access("S"."TS#"="F"."TS#" AND "S"."FILE#"="F"."RELFILE#")
 130 - filter(TO_CHAR("F"."FILE#")||'.'||TO_CHAR("S"."BLOCK#")='AUD$')
 131 - filter(("E"."KTFBUESEGFNO"="DS"."RELATIVE_FNO" AND "E"."KTFBUESEGBNO"="DS"."HEADER_BLOCK" AND "E"."KTFBUESEGTSN"="DS"."TABLESPACE_ID"))


231 rows selected.

Elapsed: 00:00:00.15

 

在查询表空间的时候,执行alter session set "_FIX_CONTROL" = "11814428:0";后,X$KTFBUE还是走全表扫描:

(表空间名字做处理)

20:32:05 SYS@eportdbi1> SELECT a.tablespace_name,
20:32:05   2    ROUND (a.bytes_alloc          / 1024 / 1024, 2) megs_alloc,
20:32:05   3    ROUND (NVL (b.bytes_free, 0)  / 1024 / 1024, 2) megs_free,
20:32:05   4    ROUND ((a.bytes_alloc         - NVL (b.bytes_free, 0)) / 1024 / 1024, 2 ) megs_used,
20:32:05   5    ROUND ((NVL (b.bytes_free, 0) / a.bytes_alloc) * 100, 2) pct_free,
20:32:05   6    100                           - ROUND ((NVL (b.bytes_free, 0) / a.bytes_alloc) * 100, 2) pct_used,
20:32:05   7    ROUND (maxbytes               / 1048576, 2) MAX
20:32:05   8  FROM
20:32:05   9    (SELECT f.tablespace_name,
20:32:05  10      SUM (f.BYTES) bytes_alloc,
20:32:05  11      SUM (DECODE (f.autoextensible, 'YES', f.maxbytes, 'NO', f.BYTES ) ) maxbytes
20:32:05  12    FROM dba_data_files f
20:32:05  13    GROUP BY tablespace_name
20:32:05  14    ) a,
20:32:05  15    (SELECT f.tablespace_name,
20:32:05  16      SUM (f.BYTES) bytes_free
20:32:05  17    FROM dba_free_space f
20:32:05  18    GROUP BY tablespace_name
20:32:05  19    ) b
20:32:05  20  WHERE a.tablespace_name = b.tablespace_name(+)
20:32:05  21  UNION ALL
20:32:05  22  SELECT h.tablespace_name,
20:32:05  23    ROUND (SUM (h.bytes_free           + h.bytes_used) / 1048576, 2) megs_alloc,
20:32:05  24    ROUND ( SUM ((h.bytes_free         + h.bytes_used) - NVL (p.bytes_used, 0)) / 1048576, 2 ) megs_free,
20:32:05  25    ROUND (SUM (NVL (p.bytes_used, 0)) / 1048576, 2) megs_used,
20:32:05  26    ROUND ( ( SUM ( (h.bytes_free      + h.bytes_used) - NVL (p.bytes_used, 0) ) / SUM (h.bytes_used + h.bytes_free) ) * 100, 2 ) pct_free,
20:32:05  27    100                                - ROUND ( ( SUM ( (h.bytes_free + h.bytes_used) - NVL (p.bytes_used, 0) ) / SUM (h.bytes_used + h.bytes_free) ) * 100, 2 ) pct_used,
20:32:05  28    ROUND (SUM (f.maxbytes)            / 1048576, 2) MAX
20:32:05  29  FROM SYS.v_$temp_space_header h,
20:32:05  30    SYS.v_$temp_extent_pool p,
20:32:05  31    dba_temp_files f
20:32:05  32  WHERE p.file_id(+)       = h.file_id
20:32:06  33  AND p.tablespace_name(+) = h.tablespace_name
20:32:06  34  AND f.file_id            = h.file_id
20:32:06  35  AND f.tablespace_name    = h.tablespace_name
20:32:06  36  GROUP BY h.tablespace_name
20:32:06  37  ORDER BY 1 ;

TABLESPACE_NAME                MEGS_ALLOC  MEGS_FREE  MEGS_USED   PCT_FREE   PCT_USED        MAX
------------------------------ ---------- ---------- ---------- ---------- ---------- ----------
xxxxxxxxxxxxxxxx                     4096       4019         77      98.12       1.88       4096
xxxxxxxxxxxxxxxx                     8192       2283       5909      27.87      72.13       8192
xxxxxxxxxxxxxxxx                     2048       1113        935      54.35      45.65       2048
xxxxxxxxxxxxxxxx                    24576      16092       8484      65.48      34.52      24576
xxxxxxxxxxxxxxxx                     4096       4095          1      99.98        .02       4096
xxxxxxxxxxxxxxxx                     8192       8187          5      99.94        .06       8192
xxxxxxxxxxxxxxxx                     4000       3373        627      84.33      15.67       4000
xxxxxxxxxxxxxxxx                   546304     346561     199743      63.44      36.56     546304
xxxxxxxxxxxxxxxx                     4096       2969       1127      72.49      27.51       4096
xxxxxxxxxxxxxxxx                     4096       4086         10      99.76        .24       4096
xxxxxxxxxxxxxxxx                     8192       3047       5145      37.19      62.81       8192
xxxxxxxxxxxxxxxx                   276608      77078     199530      27.87      72.13     276608
xxxxxxxxxxxxxxxx                    16384       8605       7779      52.52      47.48      16384
xxxxxxxxxxxxxxxx                     4096       2944       1152      71.88      28.12       4096
xxxxxxxxxxxxxxxx                    16384       3575      12809      21.82      78.18      16384
xxxxxxxxxxxxxxxx                     4096       1074       3022      26.22      73.78       4096
xxxxxxxxxxxxxxxx                     4096       4071         25      99.39        .61       4096
xxxxxxxxxxxxxxxx                     4096       3915        181      95.58       4.42       4096
xxxxxxxxxxxxxxxx                    16384      15984        400      97.56       2.44      16384
xxxxxxxxxxxxxxxx                    32760    8390.88   24369.13      25.61      74.39   32767.98
xxxxxxxxxxxxxxxx                     5360      34.13    5325.88        .64      99.36   32767.98
xxxxxxxxxxxxxxxx                     4096       2946       1150      71.92      28.08       4096
xxxxxxxxxxxxxxxx                     4096       4052         44      98.93       1.07       4096
xxxxxxxxxxxxxxxx                    20096      13860       6236      68.97      31.03      20096
xxxxxxxxxxxxxxxx                    16384      13068       3316      79.76      20.24      16384
xxxxxxxxxxxxxxxx                   208192      40933     167259      19.66      80.34     208192
xxxxxxxxxxxxxxxx                    20096      16143       3953      80.33      19.67      20096
xxxxxxxxxxxxxxxx                     2048       1898        150      92.68       7.32       2048
xxxxxxxxxxxxxxxx                    20096      16138       3958       80.3       19.7      20096
xxxxxxxxxxxxxxxx                    68096      13300      54796      19.53      80.47      68096
xxxxxxxxxxxxxxxx                     8192       8179         13      99.84        .16       8192
xxxxxxxxxxxxxxxx                    32767      31971        796      97.57       2.43   32767.98
xxxxxxxxxxxxxxxx                    10240    2371.75    7868.25      23.16      76.84      10240
xxxxxxxxxxxxxxxx                    10390    9292.25    1097.75      89.43      10.57   32767.98
xxxxxxxxxxxxxxxx                  4356.25     209.38    4146.88       4.81      95.19   32767.98

35 rows selected.

Elapsed: 00:01:54.62

 

 执行计划:

20:34:00 SYS@anonymous> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  8ks58zbpgra00, child number 1
-------------------------------------
SELECT a.tablespace_name,   ROUND (a.bytes_alloc          / 1024 /
1024, 2) megs_alloc,   ROUND (NVL (b.bytes_free, 0)  / 1024 / 1024, 2)
megs_free,   ROUND ((a.bytes_alloc         - NVL (b.bytes_free, 0)) /
1024 / 1024, 2 ) megs_used,   ROUND ((NVL (b.bytes_free, 0) /
a.bytes_alloc) * 100, 2) pct_free,   100                           -
ROUND ((NVL (b.bytes_free, 0) / a.bytes_alloc) * 100, 2) pct_used,
ROUND (maxbytes               / 1048576, 2) MAX FROM   (SELECT
f.tablespace_name,     SUM (f.BYTES) bytes_alloc,     SUM (DECODE
(f.autoextensible, 'YES', f.maxbytes, 'NO', f.BYTES ) ) maxbytes   FROM
dba_data_files f   GROUP BY tablespace_name   ) a,   (SELECT
f.tablespace_name,     SUM (f.BYTES) bytes_free   FROM dba_free_space f
  GROUP BY tablespace_name   ) b WHERE a.tablespace_name =
b.tablespace_name(+) UNION ALL SELECT h.tablespace_name,   ROUND (SUM
(h.bytes_free           + h.bytes_used) / 1048576, 2) megs_alloc,
ROUND ( SUM ((h.bytes_free         + h.bytes_used) - NVL (p.b

Plan hash value: 2506036241

------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                             | Name                 | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                      |                      |      1 |        |     35 |00:01:54.53 |   53354 |   4865 |       |       |          |
|   1 |  SORT ORDER BY                        |                      |      1 |      3 |     35 |00:01:54.53 |   53354 |   4865 |  4096 |  4096 | 4096  (0)|
|   2 |   UNION-ALL                           |                      |      1 |        |     35 |00:01:54.53 |   53354 |   4865 |       |       |          |
|*  3 |    HASH JOIN OUTER                    |                      |      1 |      2 |     34 |00:01:54.18 |   53310 |   4865 |  1229K|  1229K| 1243K (0)|
|   4 |     VIEW                              |                      |      1 |      2 |     34 |00:00:00.66 |     444 |      0 |       |       |          |
|   5 |      HASH GROUP BY                    |                      |      1 |      2 |     34 |00:00:00.66 |     444 |      0 |   941K|   941K| 1349K (0)|
|   6 |       VIEW                            | DBA_DATA_FILES       |      1 |      2 |    108 |00:00:00.65 |     444 |      0 |       |       |          |
|   7 |        UNION-ALL                      |                      |      1 |        |    108 |00:00:00.65 |     444 |      0 |       |       |          |
|   8 |         NESTED LOOPS                  |                      |      1 |      1 |      0 |00:00:00.57 |     112 |      0 |       |       |          |
|   9 |          NESTED LOOPS                 |                      |      1 |      1 |      0 |00:00:00.57 |     112 |      0 |       |       |          |
|  10 |           NESTED LOOPS                |                      |      1 |      1 |      0 |00:00:00.57 |     112 |      0 |       |       |          |
|* 11 |            FIXED TABLE FULL           | X$KCCFN              |      1 |      1 |    108 |00:00:00.57 |       0 |      0 |       |       |          |
|* 12 |            TABLE ACCESS BY INDEX ROWID| FILE$                |    108 |      1 |      0 |00:00:00.01 |     112 |      0 |       |       |          |
|* 13 |             INDEX UNIQUE SCAN         | I_FILE1              |    108 |      1 |    108 |00:00:00.01 |       4 |      0 |       |       |          |
|* 14 |           FIXED TABLE FIXED INDEX     | X$KCCFE (ind:1)      |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  15 |          TABLE ACCESS CLUSTER         | TS$                  |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 16 |           INDEX UNIQUE SCAN           | I_TS#                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  17 |         NESTED LOOPS                  |                      |      1 |      1 |    108 |00:00:00.08 |     332 |      0 |       |       |          |
|  18 |          NESTED LOOPS                 |                      |      1 |      1 |    108 |00:00:00.08 |     220 |      0 |       |       |          |
|  19 |           NESTED LOOPS                |                      |      1 |      1 |    108 |00:00:00.01 |     220 |      0 |       |       |          |
|  20 |            NESTED LOOPS               |                      |      1 |      1 |    108 |00:00:00.01 |     108 |      0 |       |       |          |
|* 21 |             FIXED TABLE FULL          | X$KCCFN              |      1 |      1 |    108 |00:00:00.01 |       0 |      0 |       |       |          |
|* 22 |             FIXED TABLE FIXED INDEX   | X$KTFBHC (ind:1)     |    108 |      1 |    108 |00:00:00.01 |     108 |      0 |       |       |          |
|* 23 |            TABLE ACCESS BY INDEX ROWID| FILE$                |    108 |      1 |    108 |00:00:00.01 |     112 |      0 |       |       |          |
|* 24 |             INDEX UNIQUE SCAN         | I_FILE1              |    108 |      1 |    108 |00:00:00.01 |       4 |      0 |       |       |          |
|* 25 |           FIXED TABLE FIXED INDEX     | X$KCCFE (ind:1)      |    108 |      1 |    108 |00:00:00.08 |       0 |      0 |       |       |          |
|  26 |          TABLE ACCESS CLUSTER         | TS$                  |    108 |      1 |    108 |00:00:00.01 |     112 |      0 |       |       |          |
|* 27 |           INDEX UNIQUE SCAN           | I_TS#                |    108 |      1 |    108 |00:00:00.01 |       4 |      0 |       |       |          |
|  28 |     VIEW                              |                      |      1 |     31 |     34 |00:01:53.52 |   52866 |   4865 |       |       |          |
|  29 |      HASH GROUP BY                    |                      |      1 |     31 |     34 |00:01:53.52 |   52866 |   4865 |  9291K|  2834K| 1346K (0)|
|  30 |       VIEW                            | DBA_FREE_SPACE       |      1 |    140 |    100K|00:01:53.50 |   52866 |   4865 |       |       |          |
|  31 |        UNION-ALL                      |                      |      1 |        |    100K|00:01:53.48 |   52866 |   4865 |       |       |          |
|  32 |         NESTED LOOPS                  |                      |      1 |      1 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|  33 |          NESTED LOOPS                 |                      |      1 |      1 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|  34 |           TABLE ACCESS FULL           | FET$                 |      1 |      1 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|* 35 |           TABLE ACCESS CLUSTER        | TS$                  |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 36 |            INDEX UNIQUE SCAN          | I_TS#                |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 37 |          INDEX UNIQUE SCAN            | I_FILE2              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  38 |         NESTED LOOPS                  |                      |      1 |     88 |  84440 |00:00:00.15 |     394 |      0 |       |       |          |
|  39 |          NESTED LOOPS                 |                      |      1 |     88 |  84440 |00:00:00.06 |     390 |      0 |       |       |          |
|* 40 |           TABLE ACCESS FULL           | TS$                  |      1 |     31 |     34 |00:00:00.01 |      38 |      0 |       |       |          |
|* 41 |           FIXED TABLE FIXED INDEX     | X$KTFBFE (ind:1)     |     34 |      3 |  84440 |00:00:00.05 |     352 |      0 |       |       |          |
|* 42 |          INDEX UNIQUE SCAN            | I_FILE2              |  84440 |      1 |  84440 |00:00:00.06 |       4 |      0 |       |       |          |
|* 43 |         HASH JOIN                     |                      |      1 |     50 |  16133 |00:01:53.30 |   52396 |   4865 |  2297K|  2297K| 2426K (0)|
|  44 |          NESTED LOOPS                 |                      |      1 |     50 |  16133 |00:01:53.29 |   52358 |   4865 |       |       |          |
|* 45 |           HASH JOIN                   |                      |      1 |    808 |  16133 |00:01:53.26 |   52354 |   4865 |  1753K|  1753K| 1511K (0)|
|* 46 |            TABLE ACCESS FULL          | RECYCLEBIN$          |      1 |    152 |    191 |00:00:00.01 |       4 |      0 |       |       |          |
|  47 |            FIXED TABLE FULL           | X$KTFBUE             |      1 |    100K|    723K|00:01:52.95 |   52350 |   4865 |       |       |          |
|* 48 |           INDEX UNIQUE SCAN           | I_FILE2              |  16133 |      1 |  16133 |00:00:00.01 |       4 |      0 |       |       |          |
|* 49 |          TABLE ACCESS FULL            | TS$                  |      1 |     31 |     34 |00:00:00.01 |      38 |      0 |       |       |          |
|  50 |         NESTED LOOPS                  |                      |      1 |      1 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|  51 |          NESTED LOOPS                 |                      |      1 |      1 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|  52 |           MERGE JOIN CARTESIAN        |                      |      1 |    425 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|* 53 |            TABLE ACCESS FULL          | TS$                  |      1 |      3 |      0 |00:00:00.01 |      38 |      0 |       |       |          |
|  54 |            BUFFER SORT                |                      |      0 |    152 |      0 |00:00:00.01 |       0 |      0 | 73728 | 73728 |          |
|* 55 |             TABLE ACCESS FULL         | RECYCLEBIN$          |      0 |    152 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  56 |           TABLE ACCESS CLUSTER        | UET$                 |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 57 |            INDEX UNIQUE SCAN          | I_FILE#_BLOCK#       |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|* 58 |          INDEX UNIQUE SCAN            | I_FILE2              |      0 |      1 |      0 |00:00:00.01 |       0 |      0 |       |       |          |
|  59 |    HASH GROUP BY                      |                      |      1 |      1 |      1 |00:00:00.35 |      44 |      0 |   856K|   856K|  463K (0)|
|  60 |     NESTED LOOPS OUTER                |                      |      1 |      1 |      1 |00:00:00.35 |      44 |      0 |       |       |          |
|* 61 |      HASH JOIN                        |                      |      1 |      1 |      1 |00:00:00.35 |      42 |      0 |  1281K|  1281K|  402K (0)|
|  62 |       NESTED LOOPS                    |                      |      1 |      1 |      1 |00:00:00.35 |       3 |      0 |       |       |          |
|  63 |        NESTED LOOPS                   |                      |      1 |      1 |      1 |00:00:00.35 |       1 |      0 |       |       |          |
|  64 |         NESTED LOOPS                  |                      |      1 |      1 |      1 |00:00:00.35 |       0 |      0 |       |       |          |
|* 65 |          FIXED TABLE FULL             | X$KCCFN              |      1 |      1 |      1 |00:00:00.34 |       0 |      0 |       |       |          |
|* 66 |          FIXED TABLE FIXED INDEX      | X$KCCTF (ind:1)      |      1 |      1 |      1 |00:00:00.01 |       0 |      0 |       |       |          |
|* 67 |         FIXED TABLE FIXED INDEX       | X$KTFTHC (ind:1)     |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |       |       |          |
|  68 |        TABLE ACCESS CLUSTER           | TS$                  |      1 |      1 |      1 |00:00:00.01 |       2 |      0 |       |       |          |
|* 69 |         INDEX UNIQUE SCAN             | I_TS#                |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |       |       |          |
|  70 |       VIEW                            | V_$TEMP_SPACE_HEADER |      1 |      1 |      1 |00:00:00.01 |      39 |      0 |       |       |          |
|  71 |        NESTED LOOPS                   |                      |      1 |      1 |      1 |00:00:00.01 |      39 |      0 |       |       |          |
|* 72 |         TABLE ACCESS FULL             | TS$                  |      1 |      1 |      1 |00:00:00.01 |      38 |      0 |       |       |          |
|* 73 |         FIXED TABLE FIXED INDEX       | X$KTFTHC (ind:2)     |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |       |       |          |
|* 74 |      VIEW PUSHED PREDICATE            | V_$TEMP_EXTENT_POOL  |      1 |      1 |      1 |00:00:00.01 |       2 |      0 |       |       |          |
|  75 |       NESTED LOOPS                    |                      |      1 |      1 |      1 |00:00:00.01 |       2 |      0 |       |       |          |
|* 76 |        TABLE ACCESS BY INDEX ROWID    | TS$                  |      1 |      1 |      1 |00:00:00.01 |       2 |      0 |       |       |          |
|* 77 |         INDEX UNIQUE SCAN             | I_TS1                |      1 |      1 |      1 |00:00:00.01 |       1 |      0 |       |       |          |
|* 78 |        FIXED TABLE FIXED INDEX        | X$KTSTFC (ind:1)     |      1 |      1 |      1 |00:00:00.01 |       0 |      0 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------------

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

   3 - access("A"."TABLESPACE_NAME"="B"."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")
  23 - filter("F"."SPARE1" IS NOT NULL)
  24 - access("FNFNO"="F"."FILE#")
  25 - filter("FE"."FENUM"="F"."FILE#")
  27 - access("HC"."KTFBHCTSN"="TS"."TS#")
  35 - filter("TS"."BITMAPPED"=0)
  36 - access("TS"."TS#"="F"."TS#")
  37 - access("F"."TS#"="FI"."TS#" AND "F"."FILE#"="FI"."RELFILE#")
  40 - filter(("TS"."BITMAPPED"<>0 AND "TS"."CONTENTS$"=0 AND INTERNAL_FUNCTION("TS"."ONLINE$")))
  41 - filter("TS"."TS#"="F"."KTFBFETSN")
  42 - access("F"."KTFBFETSN"="FI"."TS#" AND "F"."KTFBFEFNO"="FI"."RELFILE#")
  43 - access("TS"."TS#"="RB"."TS#")
  45 - access("U"."KTFBUESEGTSN"="RB"."TS#" AND "U"."KTFBUESEGFNO"="RB"."FILE#" AND "U"."KTFBUESEGBNO"="RB"."BLOCK#")
  46 - filter(("RB"."TS#" IS NOT NULL AND "RB"."FILE#" IS NOT NULL AND "RB"."BLOCK#" IS NOT NULL))
  48 - access("RB"."TS#"="FI"."TS#" AND "U"."KTFBUEFNO"="FI"."RELFILE#")
  49 - filter(("TS"."BITMAPPED"<>0 AND "TS"."CONTENTS$"=0 AND INTERNAL_FUNCTION("TS"."ONLINE$")))
  53 - filter("TS"."BITMAPPED"=0)
  55 - filter(("RB"."TS#" IS NOT NULL AND "RB"."FILE#" IS NOT NULL AND "RB"."BLOCK#" IS NOT NULL))
  57 - access("U"."TS#"="RB"."TS#" AND "U"."SEGFILE#"="RB"."FILE#" AND "U"."SEGBLOCK#"="RB"."BLOCK#")
       filter("TS"."TS#"="U"."TS#")
  58 - access("U"."TS#"="FI"."TS#" AND "U"."SEGFILE#"="FI"."RELFILE#")
  61 - access("HC"."KTFTHCTFNO"="H"."FILE_ID" AND "TS"."NAME"="H"."TABLESPACE_NAME")
  65 - filter(("V"."FNNAM" IS NOT NULL AND "V"."FNTYP"=7))
  66 - filter(("TF"."TFDUP"<>0 AND BITAND("TF"."TFSTA",32)<>32 AND "V"."FNFNO"="TF"."TFNUM" AND "TF"."TFFNH"="V"."FNNUM"))
  67 - filter("V"."FNFNO"="HC"."KTFTHCTFNO")
  69 - access("HC"."KTFTHCTSN"="TS"."TS#")
  72 - filter(("TS"."CONTENTS$"=1 AND "TS"."BITMAPPED"<>0 AND "TS"."ONLINE$"=1))
  73 - filter(("HC"."KTFTHCCVAL"=0 AND "HC"."INST_ID"=USERENV('INSTANCE') AND "TS"."TS#"="HC"."KTFTHCTSN"))
  74 - filter("P"."FILE_ID"="H"."FILE_ID")
  76 - filter(("TS"."CONTENTS$"=1 AND "TS"."BITMAPPED"<>0 AND "TS"."ONLINE$"=1))
  77 - access("TS"."NAME"="H"."TABLESPACE_NAME")
  78 - filter(("FC"."INST_ID"=USERENV('INSTANCE') AND "TS"."TS#"="FC"."KTSTFCTSN"))


147 rows selected.

Elapsed: 00:00:00.08

 

 解决可以看我另外一篇博文:Oracle查询表空间使用率很慢

 

posted @ 2020-05-15 22:32  PiscesCanon  阅读(1154)  评论(0编辑  收藏  举报