oracle中查找执行效率低下的SQL
v$sqltext:存储的是完整的SQL,SQL被分割
v$sqlarea:存储的SQL 和一些相关的信息,比如累计的执行次数,逻辑读,物理读等统计信息(统计)
v$sql:内存共享SQL区域中已经解析的SQL语句。(即时)
根据sid查找完整sql语句:
select sql_text from v$sqltext a where a.hash_value = (select sql_hash_value from v$session b where b.sid = '&sid' )
order by piece asc
select a.CPU_TIME,--CPU时间 百万分之一(微秒)
a.OPTIMIZER_MODE,--优化方式
a.EXECUTIONS,--执行次数
a.DISK_READS,--读盘次数
a.SHARABLE_MEM,--占用shared pool的内存多少
a.BUFFER_GETS,--读取缓冲区的次数
a.COMMAND_TYPE,--命令类型(3:select,2:insert;6:update;7delete;47:pl/sql程序单元)
a.SQL_TEXT,--Sql语句
a.SHARABLE_MEM,
a.PERSISTENT_MEM,
a.RUNTIME_MEM,
a.PARSE_CALLS,
a.DISK_READS,
a.DIRECT_WRITES,
a.CONCURRENCY_WAIT_TIME,
a.USER_IO_WAIT_TIME
from SYS.V_$SQLAREA a
WHERE PARSING_SCHEMA_NAME = 'CHEA_FILL'--表空间
order by a.CPU_TIME desc
引用:http://jenniferok.iteye.com/blog/700985
a.executions exec,a.disk_reads/decode(a.executions,0,1,a.executions) rds_exec_ratio,
a.sql_text Statement
from v$sqlarea a,dba_users b
where a.parsing_user_id=b.user_id
and a.disk_reads > 100000
order by a.disk_reads desc;
from (select sql_text,executions,
rank() over
(order by executions desc) exec_rank
from v$sql)
where exec_rank <=5;
select disk_reads,sql_text
from (select sql_text,disk_reads,
dense_rank() over
(order by disk_reads desc) disk_reads_rank
from v$sql)
where disk_reads_rank <=5;
from (select sql_text,buffer_gets,
dense_rank() over
(order by buffer_gets desc) buffer_gets_rank
from v$sql)
where buffer_gets_rank<=5;
SQL_TEXT |
VARCHAR2(1000) |
First thousand characters of the SQL text for the current cursor |
SQL_ID |
VARCHAR2(13) |
SQL identifier of the parent cursor in the library cache |
SHARABLE_MEM |
NUMBER |
Amount of shared memory used by a cursor. If multiple child cursors exist, then the sum of all shared memory used by all child cursors. |
PERSISTENT_MEM |
NUMBER |
Fixed amount of memory used for the lifetime of an open cursor. If multiple child cursors exist, the fixed sum of memory used for the lifetime of all the child cursors. |
RUNTIME_MEM |
NUMBER |
Fixed amount of memory required during execution of a cursor. If multiple child cursors exist, the fixed sum of all memory required during execution of all the child cursors. |
SORTS |
NUMBER |
Sum of the number of sorts that were done for all the child cursors |
VERSION_COUNT |
NUMBER |
Number of child cursors that are present in the cache under this parent |
LOADED_VERSIONS |
NUMBER |
Number of child cursors that are present in the cache and have their context heap (KGL heap 6) loaded |
OPEN_VERSIONS |
NUMBER |
The number of child cursors that are currently open under this current parent |
USERS_OPENING |
NUMBER |
Number of users that have any of the child cursors open |
FETCHES |
NUMBER |
Number of fetches associated with the SQL statement |
EXECUTIONS |
NUMBER |
Total number of executions, totalled over all the child cursors |
END_OF_FETCH_COUNT |
NUMBER |
Number of times this cursor was fully executed since the cursor was brought into the library cache. The value of this statistic is not incremented when the cursor is partially executed, either because it failed during the execution or because only the first few rows produced by this cursor are fetched before the cursor is closed or re-executed. By definition, the value of the END_OF_FETCH_COUNT column should be less or equal to the value of theEXECUTIONS column. |
USERS_EXECUTING |
NUMBER |
Total number of users executing the statement over all child cursors |
LOADS |
NUMBER |
Number of times the object was loaded or reloaded |
FIRST_LOAD_TIME |
VARCHAR2(19) |
Timestamp of the parent creation time |
INVALIDATIONS |
NUMBER |
Total number of invalidations over all the child cursors |
PARSE_CALLS |
NUMBER |
Sum of all parse calls to all the child cursors under this parent |
DISK_READS |
NUMBER |
Sum of the number of disk reads over all child cursors |
DIRECT_WRITES |
NUMBER |
Sum of the number of direct writes over all child cursors |
BUFFER_GETS |
NUMBER |
Sum of buffer gets over all child cursors |
APPLICATION_WAIT_TIME |
NUMBER |
Application wait time |
CONCURRENCY_WAIT_TIME |
NUMBER |
Concurrency wait time |
CLUSTER_WAIT_TIME |
NUMBER |
Cluster wait time |
USER_IO_WAIT_TIME |
NUMBER |
User I/O Wait Time |
PLSQL_EXEC_TIME |
NUMBER |
PL/SQL execution time |
JAVA_EXEC_TIME |
NUMBER |
Java execution time |
ROWS_PROCESSED |
NUMBER |
Total number of rows processed on behalf of this SQL statement |
COMMAND_TYPE |
NUMBER |
Oracle command type definition |
OPTIMIZER_MODE |
VARCHAR2(25) |
Mode under which the SQL statement was executed |
PARSING_USER_ID |
NUMBER |
User ID of the user that has parsed the very first cursor under this parent |
PARSING_SCHEMA_ID |
NUMBER |
Schema ID that was used to parse this child cursor |
KEPT_VERSIONS |
NUMBER |
Number of child cursors that have been marked to be kept using theDBMS_SHARED_POOL package |
ADDRESS |
RAW(4 | 8) |
Address of the handle to the parent for this cursor |
HASH_VALUE |
NUMBER |
Hash value of the parent statement in the library cache |
OLD_HASH_VALUE |
NUMBER |
Old SQL hash value |
MODULE |
VARCHAR2(64) |
Contains the name of the module that was executing at the time that the SQL statement was first parsed as set by calling DBMS_APPLICATION_INFO .SET_MODULE |
MODULE_HASH |
NUMBER |
Hash value of the module that is named in the MODULE column |
ACTION |
VARCHAR2(64) |
Contains the name of the action that was executing at the time that the SQL statement was first parsed as set by calling DBMS_APPLICATION_INFO .SET_ACTION |
ACTION_HASH |
NUMBER |
Hash value of the action that is named in the ACTION column |
SERIALIZABLE_ABORTS |
NUMBER |
Number of times the transaction fails to serialize, producing ORA-08177 errors, totalled over all the child cursors |
CPU_TIME |
NUMBER |
CPU time (in microseconds) used by this cursor for parsing/executing/fetching |
ELAPSED_TIME |
NUMBER |
Elapsed time (in microseconds) used by this cursor for parsing/executing/fetching |
IS_OBSOLETE |
VARCHAR2(1) |
Indicates whether the cursor has become obsolete (Y ) or not (N ). This can happen if the number of child cursors is too large. |
CHILD_LATCH |
NUMBER |
Child latch number that is protecting the cursor |
PROGRAM_ID |
NUMBER |
Program identifie |
oracle中查找执行效率低下的SQL的更多相关文章
- 转://看懂Oracle中的执行计划
一.什么是Oracle执行计划? 执行计划是一条查询语句在Oracle中的执行过程或访问路径的描述 二.怎样查看Oracle执行计划? 2.1 explain plan for命令查看执行计划 在sq ...
- Mysql 定位执行效率低的sql 语句
一.通过MySQL慢查询日志定位执行效率低的SQL语句. MySQL通过慢查询日志定位那些执行效率较低的SQL 语句,用--log-slow-queries[=file_name]选项启动时,mysq ...
- Oracle中获取执行计划的几种方法分析
以下是对Oracle中获取执行计划的几种方法进行了详细的分析介绍,需要的朋友可以参考下 1. 预估执行计划 - Explain PlanExplain plan以SQL语句作为输入,得到这条S ...
- 在oracle中通过链接服务器(dblink)访问sql server
在oracle中通过链接服务器(dblink)访问sql server 2013-10-16 一. 工作环境: <1> Oracle数据库版本:Oracle 11g 运行环境 :IB ...
- oracle中查找和删除重复记录的几种方法总结
平时工作中可能会遇到当试图对库表中的某一列或几列创建唯一索引时,系统提示 ORA-01452 :不能创建唯一索引,发现重复记录. 下面总结一下几种查找和删除重复记录的方法(以表CZ为例): 表CZ的结 ...
- Oracle中的执行计划
使用autotrace sqlplus系统参数:SQL> set autotrace trace onSQL> select * from dual;DUM---XExecution Pl ...
- Oracle中查找某个点半径范围内的所有经纬度(优化)
需求: 已知一个点的经纬度,需要从表中找出以这个点为中心,半径M米范围内的所有经纬度数据. 假设现有表 TAB_LONG_LAT_DATA,字段如下: ID INTE ...
- Oracle中的内置函数在sql中的转换整理
程序里面经常会即支持Oracle数据库,又支持sql数据库.而有些Oracle内置函数用的比较多,但在sql中语法有些不同,我做了些整理,希望可以帮助大家.... 1.oracle中的内置函数:ora ...
- C#中 如何执行带GO的sql 语句
C#中是不允许执行带GO的sql 语句的, 如何做呢? 思路就是将带GO的sql语句转化为分段执行, 但在同一事务内执行. 扩展方法是个很不错的主意, 但是尽量不要影响原来的cmd的一些东东, 如 c ...
随机推荐
- hdu 4686 Arc of Dream(矩阵快速幂乘法)
Problem Description An Arc of Dream is a curve defined by following function: where a0 = A0 ai = ai- ...
- the first has precedence, perhaps you need a NameVirtualHost directive
报错信息1: Starting httpd: [Fri May 19 11:49:42 2011] [warn] VirtualHost 127.0.0.1:80 overl aps with Vir ...
- 自动工作负载库(Automatic Workload Repository,AWR)
自动工作负载库(Automatic Workload Repository,AWR)AWR的由来: 10g之前的oracle:用户的连接将产生会话,当前会话记录保存在v$session中:处于等 ...
- 使用FileSystemWatcher捕获系统文件状态
源代码: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Sys ...
- Javascript 【JSON对象】
var box = JSON.parse(json); //将字符串解析为JSON var json = JSON.stringify(box); //讲JSON转换为字符串 var b ...
- Oracle的分页查询语句优化
Oracle的分页查询语句基本上可以按照本文给出的格式来进行套用. (一) 分页查询格式: SELECT * FROM ( SELECT A.*, ROWNUM RN FROM (SELECT ...
- xcode中控件共有属性
Text,title 控件上的文字 backgroung 背景图片或颜色 alignment 布局(居中,..) mode显示模式(缩放,拉伸..) drawing 隐藏控件的可见性 alpha 透明 ...
- Android ImageView图片自适应
网络上下载下来的图片自适应:android:adjustViewBounds="true"(其详细解释在下面) <ImageView android:id=" ...
- zoj1107 FatMouse and Cheese
这是一道记忆化搜索,也就是有记录的搜索. 注意点:一次走k步不能拐弯 int bfs(int x,int y) { ; ) return ans[x][y]; ;i<;i++) { ;j< ...
- Ubuntu 12.04 下安装git
---恢复内容开始--- 1.安装build-essential. 列出Git相关包(git-core 和 git-doc)所以来的各个安装包并安装: sudo apt-get build-dep g ...