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;


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值