Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 如何检查执行查询的次数?_Performance_Oracle_Oracle11g_Monitoring_Database Administration - Fatal编程技术网

Performance 如何检查执行查询的次数?

Performance 如何检查执行查询的次数?,performance,oracle,oracle11g,monitoring,database-administration,Performance,Oracle,Oracle11g,Monitoring,Database Administration,我正在使用Oracle 11gr2数据库。有没有办法检查一个特定查询执行了多少次,以及当前日期或过去24小时内执行该查询的总运行时间是多少?它类似于sql运行时的历史。请提供您的建议 select sql_text, sql_fulltext, executions, elapsed_time/1000000 seconds from gv$sql order by executions desc; 这将只返回尚未从共享池中过期的查询,并且只提供累积运行时间。但是,如果您只对最常见的查询感兴趣

我正在使用Oracle 11gr2数据库。有没有办法检查一个特定查询执行了多少次,以及当前日期或过去24小时内执行该查询的总运行时间是多少?它类似于sql运行时的历史。请提供您的建议

select sql_text, sql_fulltext, executions, elapsed_time/1000000 seconds
from gv$sql
order by executions desc;
这将只返回尚未从共享池中过期的查询,并且只提供累积运行时间。但是,如果您只对最常见的查询感兴趣,那么它们很可能是最近使用过的,不会过时

AWR报告或DBA_HIST_*表也可能有所帮助。如果您有网格控件,您可以非常轻松地选择24小时时间段并生成一个报告,该报告将显示最重要的查询


更新:

我不认为有任何方法可以获得每个执行的统计数据。历史性能视图是通过采样工作的,它们不能捕获所有内容。实际上,这对于性能调优来说已经足够了。如果某件事情发生的频率不够高,不值得进行调整

AWR可用于确定每天执行的大致数量:

--Number of Executions today.
select 
    --Executions at last snap.
    (
        select executions_total
        from dba_hist_sqlstat
        where snap_id = 
            (
                --Latest snapshot.
                select max(snap_id) keep 
                    (dense_rank last order by begin_interval_time) end_snap_id
                from dba_hist_snapshot
            )
            and sql_id = '5ms6rbzdnq16t'
    )   
    -
    --Executions at beginning of day.
    (
        select executions_total
        from dba_hist_sqlstat
        where snap_id = 
            (
                --Snapshot for beginning of the day.
                --Assumes there are hourly snapshots that start on time.
                select snap_id begin_snap_id
                from dba_hist_snapshot
                where trunc(begin_interval_time, 'hh') = trunc(sysdate)
            )
            and sql_id = '5ms6rbzdnq16t'
    ) executions_today
from dual;

查询是否有绑定变量?我正在寻找一个脚本,该脚本可用于两种类型的查询,一种是有绑定变量的查询,另一种是没有绑定变量的查询。查看V$sqlarea视图。我有一个查询的SQLId,该查询是从OEM生成的AWR报告中获得的,我实际上想知道该查询今天执行了多少次,以及每次执行的时间执行?从上面的查询中,我在第4行得到了这个错误:ORA-01427:single row子查询返回多行,这可能是因为我假设每小时快照一次。或者同一个SQL\u ID有多个具有不同计划哈希值的行?您需要修改查询以满足您的需要。