国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

在Oracle10g Release 2中的Autotrace

2024-08-29 13:42:37
字體:
供稿:網(wǎng)友
   今天在測試過程中,偶然發(fā)現(xiàn)在Oracle10g Release 2中,Autotrace的功能已經(jīng)被極大加強和改變。
  
  這是一個很有意思的小的變化,關(guān)于autotrace的使用,請參考:啟用AutoTrace
  
  接下來讓我們先來看一下什么地方發(fā)生了改變: SQL> set linesize 120
  
  SQL> set autotrace on
  SQL> select count(*) from v$session
   2 /
  
   COUNT(*)
  ----------
      21
  
  
  Execution Plan
  ----------------------------------------------------------
  Plan hash value: 2376410614
  
  ---------------------------------------------------------------------------------------------
   Id  Operation         Name       Rows  Bytes Cost (%CPU) Time  
  ---------------------------------------------------------------------------------------------
    0 SELECT STATEMENT                 1   65    0  (0) 00:00:01
    1  SORT AGGREGATE                  1   65            
    2   NESTED LOOPS                  1   65    0  (0) 00:00:01
  * 3   FIXED TABLE FULL    X$KSUSE        1   52    0  (0) 00:00:01
  * 4   FIXED TABLE FIXED INDEX X$KSLED (ind:2)    1   13    0  (0) 00:00:01
  ---------------------------------------------------------------------------------------------
  
  PRedicate Information (identified by operation id):
  ---------------------------------------------------
  
    3 - filter("S"."INST_ID"=USERENV('INSTANCE') AND BITAND("S"."KSSPAFLG",1)<>0 AND
         BITAND("S"."KSUSEFLG",1)<>0)
    4 - filter("S"."KSUSEOPC"="E"."INDX")
  
  
  Statistics
  ----------------------------------------------------------
  1 recursive calls
  0 db block gets
  0 consistent gets
  0 physical reads
  0 redo size
  411 bytes sent via SQL*Net to client
  385 bytes received via SQL*Net from client
  2 SQL*Net roundtrips to/from client
  0 sorts (memory)
  0 sorts (disk)
  1 rows processed
  
  注重,此時autotrace的輸出被良好格式化,并給出關(guān)于執(zhí)行計劃部分的簡要注釋。
  其實這里并沒有帶來新的東西,從Oracle9i開始,Oracle提供了一個新的工具dbms_XPlan用以格式化和查看SQL的執(zhí)行計劃。其原理是通過對plan_table的查詢和格式化提供更友好的用戶輸出。
  
  dbms_xplan的調(diào)用的語法類似:
  select * from table(dbms_xplan.display(format=>'BASIC'))
  使用 TABLE() 操作符,或者 CAST 操作。
  
  具體用法可以參考Oracle官方文檔。
  
  實際上從Oracle9i開始我們就經(jīng)常使用如下方式調(diào)用dbms_xplan:
  Connected to:
  Oracle9i Enterprise Edition Release 9.2.0.4.0 - ProdUCtion
  With the Partitioning option
  JServer Release 9.2.0.4.0 - Production
  
  SQL> explain plan for
   2 select count(*) from dual;
  
  Explained.
  
  SQL> @?/rdbms/admin/utlxplp;
  
  PLAN_TABLE_OUTPUT
  ----------------------------------------------------------------------------------
  
  --------------------------------------------------------------------
   Id  Operation       Name    Rows  Bytes Cost 
  --------------------------------------------------------------------
    0 SELECT STATEMENT                     
    1  SORT AGGREGATE                     
    2   TABLE access FULL  DUAL               
  --------------------------------------------------------------------
  
  Note: rule based optimization
  
  10 rows selected.
  
  utlxplp.sql腳本中正是調(diào)用了dbms_xplan:
  
  SQL> get ?/rdbms/admin/utlxplp;
  1 Rem
  2 Rem $Header: utlxplp.sql 23-jan-2002.08:55:23 bdagevil Exp $
  3 Rem
  4 Rem utlxplp.sql
  5 Rem
  6 Rem Copyright (c) 1998, 2002, Oracle Corporation. All rights reserved.
  7 Rem
  8 Rem  NAME
  9 Rem   utlxplp.sql - UTiLity eXPLain Parallel plans
  10 Rem
  11 Rem  DESCRIPTION
  12 Rem   script utility to display the explain plan of the last explain plan
  13 Rem     command. Display also Parallel Query information if the plan happens to
  14 Rem   run parallel
  15 Rem
  16 Rem  NOTES
  17 Rem   Assume that the table PLAN_TABLE has been created. The script
  18 Rem   utlxplan.sql should be used to create that table
  19 Rem
  20 Rem   With SQL*plus, it is recomended to set linesize and pagesize before
  21 Rem   running this script. For example:
  22 Rem      set linesize 130
  23 Rem      set pagesize 0
  24 Rem
  25 Rem  MODIFIED  (MM/DD/YY)
  26 Rem  bdagevil  01/23/02 - rewrite with new dbms_xplan package
  27 Rem  bdagevil  04/05/01 - include CPU cost
  28 Rem  bdagevil  02/27/01 - increase Name column
  29 Rem  jihuang   06/14/00 - change order by to order siblings by.
  30 Rem  jihuang   05/10/00 - include plan info for recursive SQL in LE row source
  31 Rem  bdagevil  01/05/00 - make deterministic with order-by
  32 Rem  bdagevil  05/07/98 - Explain plan script for parallel plans
  33 Rem  bdagevil  05/07/98 - Created
  34 Rem
  35 set markup Html preformat on
  36 Rem
  37 Rem Use the display table function from the dbms_xplan package to display the last
  38 Rem explain plan. Use default mode which will display only relevant information
  39 Rem
  40* select * from table(dbms_xplan.display());
  41
  SQL>
  
  而在Oracle10gR2中,Oracle幫我們簡化了這個過程,一個autotrace就完成了所有的輸出,這也是易用性上的一個進步吧。在使用 Oracle的過程中,我們經(jīng)常能夠感受到Oracle針對用戶需求或易用性的改進,這也許是很多人喜愛Oracle的一個原因吧。
  
  假如足夠信息我們還會注重到,在Oracle10g中PLAN_TABLE不再需要創(chuàng)建,Oracle缺省增加了一個字典表PLAN_TABLE$,然后基于PLAN_TABLE$創(chuàng)建公用同義詞供用戶使用。
  
  關(guān)于dbms_xplan工具的使用還可以參考Itpub上的討論:使用dbms_xplan工具查看執(zhí)行計劃.
  

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 内丘县| 新民市| 饶河县| 全南县| 溆浦县| 边坝县| 临颍县| 台北市| 调兵山市| 隆林| 天气| 阿坝县| 彭山县| 台东市| 大埔县| 昭平县| 玛纳斯县| 黄大仙区| SHOW| 尤溪县| 报价| 张掖市| 樟树市| 永德县| 吴江市| 大足县| 嘉禾县| 象山县| 盐亭县| 文成县| 庆元县| 科尔| 康保县| 宁远县| 双城市| 平阴县| 阿拉善盟| 陈巴尔虎旗| 丹阳市| 重庆市| 麻江县|