打印本文 打印本文 关闭窗口 关闭窗口
在SQL*PLUS中应用AUTOTRACE REPORT
作者:武汉SEO闵涛  文章来源:敏韬网  点击数4766  更新时间:2007/11/14 11:01:37  文章录入:mintao  责任编辑:mintao
J

安装AUTOTRACE报告(Setups Required for the AUTOTRACE Report)

要用这个特性,用户必须被赋予PLUSTRACE角色,而PLUSTRACE角色需要DBA来赋予。另外,该用户必须创建PLAN_TABLE表。

I.                 首先创建PLUSTRACE角色并且赋给DBA:

CONNECT sys/sys’s password AS SYSDBA 
@$ORACLE_HOME/sqlplus/admin/plustrce.sql

II.              赋权限给用户

CONNECT / AS SYSDBA 

GRANT PLUSTRACE TO USER(预赋权的用户名);

 

这样,就可以在该用户下设置AUTOTRACE报告的显示与否了。

 

AUTOTRACE报告中涉及到的两个方面的内容

I.              SQL语句的执行计划

执行计划就是SQL优化器执行语句的查询执行顺序,每一行的执行计划都会有个行号,这个行号是连续的

II.          SQL语句的数据库统计

数据库统计是服务器记录的执行当前的这条语句所需要的系统资源等,主要包括下表的内容

Database Statistic Name

Description

recursive calls

Number of recursive calls generated at both the user and system level. Oracle maintains tables used for internal processing. When Oracle needs to make a change to these tables, it internally generates an internal SQL statement, which in turn generates a recursive call.

db block gets

Number of times a CURRENT block was requested.

consistent gets

Number of times a consistent read was requested for a block.

physical reads

Total number of data blocks read from disk. This number equals the value of "physical reads direct" plus all reads into buffer cache.

redo size

Total amount of redo generated in bytes.

bytes sent via SQL*Net to client

Total number of bytes sent to the client from the foreground processes.

bytes received via SQL*Net from client

Total number of bytes received from the client over Oracle Net.

SQL*Net roundtrips to/from client

Total number of Oracle Net messages sent to and received from the client.

sorts (memory)

Number of sort operations that were performed completely in memory and did not require any disk writes.

sorts (disk)

Number of sort operations that required at least one disk write.

rows processed

Number of rows processed during the operation.

 

简单使用的例子:

SQL> show user

USER is "SYS"

(注:当前是sysdba用户)

(注:创建PLUSTRACE角色并且赋给DBA)

SQL> start $ORACLE_HOME/sqlplus/admin/plustrce.sql

(注:start 等价于@)

SQL> drop role plustrace;

drop role plustrace

          *

ERROR at line 1:

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口