解決autotrace不顯示Predicate Information的問題

來源:互聯網
上載者:User

用autotrace在有的資料庫上可以看到Predicate Information,有時候看不到,原因是plan_table版本舊所致,解決方案如下:

SQL>set autotrace traceonly

SQL> select u.name
2 from user u
3 where u.department_id in (select d.department_id from department d);

執行計畫
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5251 | 89267 | 15 (7)|
| 1 | NESTED LOOPS | | 5251 | 89267 | 15 (7)|
| 2 | TABLE ACCESS FULL| USER | 5273 | 63276 | 14 (0)|
| 3 | INDEX UNIQUE SCAN| PK_DEPARTMENT | 1 | 5 | 0 (0)|
-----------------------------------------------------------------------------
Note
-----
- 'PLAN_TABLE' is old version
統計資訊
----------------------------------------------------------
1 recursive calls
0 db block gets
6024 consistent gets
0 physical reads
0 redo size
72158 bytes sent via SQL*Net to client
4156 bytes received via SQL*Net from client
348 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5195 rows processed

處理方法:
drop table PLAN_TABLE;
@?/rdbms/admin/utlxplan

SQL> select u.name
2 from user u
3 where u.department_id in (select d.department_id from department d);

執行計畫
----------------------------------------------------------
Plan hash value: 2264021098

----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 5251 | 89267 | 15 (7)| 00:00:01 |
| 1 | NESTED LOOPS | | 5251 | 89267 | 15 (7)| 00:00:01 |
| 2 | TABLE ACCESS FULL| USER | 5273 | 63276 | 14 (0)| 00:00:01 |
|* 3 | INDEX UNIQUE SCAN| PK_DEPARTMENT | 1 | 5 | 0 (0)| 00:00:01 |
----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("U"."DEPARTMENT_ID"="D"."DEPARTMENT_ID")

統計資訊
----------------------------------------------------------
0 recursive calls
0 db block gets
6024 consistent gets
0 physical reads
0 redo size
72158 bytes sent via SQL*Net to client
4156 bytes received via SQL*Net from client
348 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
5195 rows processed

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.