Think different

困难并没有自己想得那么难,所谓的困难,很多都是自己想像出来的。

Enabling Tracing in Your Application

If you own the source code to theapplication you wish to trace, it might be feasible for you to modify the codedirectly to enable SQL Trace. This can be advantageous because you can enableSQL Trace at precisely the point in your application where you have a doubt.This can greatly narrow the scope of your tracing exercise, allowing you tofocus efforts on the bottleneck itself.

Depending on the tools used to build yourapplication, you may be able to enable SQL Trace with the simple command:

ALTER SESSION SET SQL_TRACE = TRUE;
If you need to enable SQL Trace from withina PL/SQL block, you can call:
dbms_session.set_sql_trace (TRUE);

SQL Trace output is most valuable when timedstatistics are enabled. You can instantly enable timed statistics for allsessions by logging on to the database as a DBA and executing the command:

ALTER SYSTEM SET TIMED_STATISTICS = TRUE;

If you are concerned about the overhead thiscauses, you may instead modify the application code to enable timed statisticsfor the current session instead of the entire instance. You can do this withthe command:

ALTER SESSION SET TIMED_STATISTICS = TRUE;

To enable timed statistics from within aPL/SQL block, you must use the dbms_sql package to build and execute a dynamicSQL statement:

DECLARE
  c INTEGER; i INTEGER;
BEGIN
  c := dbms_sql.open_cursor;
  dbms_sql.parse (c, 'ALTER SESSION SET TIMED_STATISTICS = TRUE',
                  dbms_sql.native);
  i := dbms_sql.execute (c);
  dbms_sql.close_cursor (c);
END;


阅读更多
个人分类: Oracle Management
上一篇ORACLE_OCM.MGMT_CONFIG_JOB_2_2 ORA-12012
下一篇Sql Tuning Advisor
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭