打对了

实践Oracle优化技术在医疗信息化中的深入应用,探索医院信息系统性能优化设计之道。公众号:医信系统性能优化。

 

如何建立Autotrace环境

创建plan_table表为临时表,并且授权给所有人可用,再建立plustrace并授权.

Ora81\RDBMS\ADMIN\utlxplan.sql
修改为创建临时表
create global TEMPORARY table PLAN_TABLE ( )
on commit preserve ROWS;

再执行@D:\oracle\Ora81\RDBMS\ADMIN\utlxplan.sql

grant all privilege on plan_table to public;
create public synonym plan_table for plan_table;

@D:\oracle\ora81\sqlplus\admin\plustrce.sql
grant plustrace to public;

然后就可以在SQL_PLUS中使用了:
SQL> column plan_plus_exp format a200;
SQL> set linesize 5000
SQL> set pagesize 999

SQL> alter session set timed_STATISTICS=true;
SQL> set autotrace on;

SQL> set autotrace traceonly;( on explan,on statistics,traceonly explan,traceonly statistics)
结束
SQL> set autotrace off;


SQL> Select 名称, To_Char(登记日期, 'YYYY-MM-DD')
  2  From 用户目录
  3  Where 登记日期 > Sysdate - 50 And 显示类型 = 1 And Rownum <= 5
  4  Order By 登记日期 Desc;


Execution Plan
----------------------------------------------------------
   0      SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=31)
   1    0   COUNT (STOPKEY)
   2    1     TABLE ACCESS (BY INDEX ROWID) OF '用户目录' (Cost=1 Card
          =1 Bytes=31)

   3    2       INDEX (RANGE SCAN DESCENDING) OF '用户目录_IX_登记日期
          ' (NON-UNIQUE) (Cost=2 Card=1)

Statistics
----------------------------------------------------------
          0  recursive calls
          0  db block gets
          5  consistent gets
          0  physical reads
          0  redo size
        734  bytes sent via SQL*Net to client
        425  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          1  sorts (memory)
          0  sorts (disk)
          5  rows processed

posted on 2006-04-04 10:59  知道得越多知道的越少  阅读(369)  评论(0编辑  收藏  举报

导航