【问题标题】:Calculate Actual execution of query in oracle计算oracle中查询的实际执行情况
【发布时间】:2014-04-02 10:30:07
【问题描述】:

有人可以建议我们如何计算查询的实际执行情况。没有 IO 操作。

目前,我正在使用以下方法:

variable n number
exec :n := dbms_utility.get_time
PROMPT The time consumed with Function Call
SET SERVEROUTPUT ON;
variable n number
exec :n := dbms_utility.get_time
set term off;

  select   -- My Select Query

SET TERM ON;
exec dbms_output.put_line( dbms_utility.get_time - :n )

这是计算查询执行时间的正确方法吗?

【问题讨论】:

  • “设置时间”更容易
  • 实际上选择查询会产生非常大的数据,据我了解,IO 操作需要更多时间然后从数据库中检索。使用 SET TERM OFF 我无法找到消耗的时间。

标签: sql oracle oracle11g sqlplus


【解决方案1】:

我想你使用 SQLTrace。

在运行查询之前:

     ALTER SESSION SET sql_trace = true;
     ALTER SESSION SET tracefile_identifier = [sqltrace_identifier_which_will_be_included_into_output_filename];

然后运行您的查询并将跟踪设置为关闭:

     ALTER SESSION SET sql_trace = false;

现在您已经生成了一个跟踪文件。在 USER_DUMP_DEST 文件夹中查找跟踪文件。 但它对人类并不友好。 使用 tkprof 实用程序将其转换为可读格式(将“input.trc”替换为您的文件名。您的文件名包含您在 tracefile_identifier 参数中设置的标识符):

     tkprof input.trc output.prf

阅读 output.prf 文件并享受 :)

一些详细的解释:

http://www.orafaq.com/wiki/SQL_Trace http://www.orafaq.com/wiki/TKProf

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-02
    • 1970-01-01
    • 2020-01-06
    • 2016-05-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多