使用10046追踪执行计划demo
(一)开启10046追踪
SQL> alter session set events '10046 trace name context forever,level 12';
(二)执行sql语句
SELECT J.JOB_ID,
J.JOB_TITLE,
J.MIN_SALARY,
J.MAX_SALARY,
E.EMPLOYEE_ID,
E.FIRST_NAME || E.LAST_NAME AS NAME,
E.EMAIL,
E.PHONE_NUMBER
FROM JOBS J, EMPLOYEES E
WHERE J.JOB_ID = E.JOB_ID;
(三)关闭追踪
SQL> alter session set events '10046 trace name context off';
(四)在查看alert目录里面找到新生成的文件,执行分析
(4.1)找到文件
[oracle@rac1 trace]$ pwd /u01/app/oracle/diag/rdbms/rac/rac1/trace [oracle@rac1 trace]$ ls -lrt ... ... -rw-r----- 1 oracle asmadmin 196 Jan 14 15:41 rac1_ora_27998.trm -rw-r----- 1 oracle asmadmin 9530 Jan 14 15:41 rac1_ora_27998.trc
(4.2)解析trc文件
[oracle@rac1 trace]$ tkprof rac1_ora_27998.trc lijiaman_10046.txt sys=no sort=prsela,exeela,fchela
(4.3)查看解析后的文件
[oracle@rac1 trace]$ ls -lrt
...
-rw-r----- 1 oracle asmadmin 112680 Jan 14 15:39 rac1_ora_12468.trc
-rw-r----- 1 oracle asmadmin 196 Jan 14 15:41 rac1_ora_27998.trm
-rw-r----- 1 oracle asmadmin 9530 Jan 14 15:41 rac1_ora_27998.trc
-rw-r--r-- 1 oracle oinstall 8587 Jan 14 15:43 lijiaman_10046.txt
附录:解析后文件信息
TKPROF: Release 11.2.0.1.0 - Development on Sun Jan 14 15:43:44 2018
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
Trace file: rac1_ora_27998.trc
Sort options: prsela exeela fchela
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
select j.job_id,
j.job_title,
j.min_salary,
j.max_salary,
e.employee_id,
e.first_name||e.last_name as name,
e.email,
e.phone_number
from jobs j,employees e
where j.job_id = e.job_id
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 11 0 107
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 4 0.00 0.00 0 11 0 107
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
107 MERGE JOIN (cr=11 pr=0 pw=0 time=2014 us cost=6 size=8988 card=107)
19 TABLE ACCESS BY INDEX ROWID JOBS (cr=4 pr=0 pw=0 time=90 us cost=2 size=627 card=19)
19 INDEX FULL SCAN JOB_ID_PK (cr=2 pr=0 pw=0 time=18 us cost=1 size=0 card=19)(object id 73932)
107 SORT JOIN (cr=7 pr=0 pw=0 time=78 us cost=4 size=5457 card=107)
107 TABLE ACCESS FULL EMPLOYEES (cr=7 pr=0 pw=0 time=106 us cost=3 size=5457 card=107)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 0.86 0.93
Disk file operations I/O 1 0.00 0.00
********************************************************************************
SQL ID: 9m7787camwh4m
Plan Hash: 0
begin :id := sys.dbms_transaction.local_transaction_id; end;
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 4 0.00 0.00 0 0 0 0
Execute 4 0.00 0.00 0 0 0 4
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 8 0.00 0.00 0 0 0 4
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 85
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 4 0.00 0.00
SQL*Net message from client 4 60.12 72.13
********************************************************************************
SQL ID: 5x323vaz5nuu4
Plan Hash: 0
alter session set events '10046 trace name context off'
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: 85
********************************************************************************
SQL ID: cf06fwacdmgfk
Plan Hash: 1388734953
select 'x'
from
dual
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 0.00 0.00 0 0 0 2
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 6 0.00 0.00 0 0 0 2
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 85
Rows Row Source Operation
------- ---------------------------------------------------
1 FAST DUAL (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 5 0.00 0.00
SQL*Net message from client 5 0.01 0.02
rdbms ipc reply 3 0.00 0.00
********************************************************************************
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 8 0.00 0.00 0 0 0 0
Execute 8 0.00 0.00 0 0 0 4
Fetch 4 0.00 0.00 0 11 0 109
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 20 0.00 0.00 0 11 0 113
Misses in library cache during parse: 1
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 12 0.00 0.00
SQL*Net message from client 12 60.12 73.09
rdbms ipc reply 3 0.00 0.00
Disk file operations I/O 1 0.00 0.00
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
8 user SQL statements in session.
0 internal SQL statements in session.
8 SQL statements in session.
********************************************************************************
Trace file: rac1_ora_27998.trc
Trace file compatibility: 11.1.0.7
Sort options: prsela exeela fchela
1 session in tracefile.
8 user SQL statements in trace file.
0 internal SQL statements in trace file.
8 SQL statements in trace file.
4 unique SQL statements in trace file.
152 lines in trace file.
73 elapsed seconds in trace file.
【完】
使用10046追踪执行计划demo的更多相关文章
- 使用 10046 查看执行计划并读懂 trace 文件
查看 sql 执行计划的方法有许多种, 10046 事件就是其中的一种. 与其他查看 sql 执行计划不同, 当我们遇到比较复杂的 sql 语句, 我们可以通过 10046 跟踪 sql 得到执行计划 ...
- 使用awrsqrpt.sql查看执行计划demo
SQL> @?/rdbms/admin/awrsqrpt.sql Current Instance ~~~~~~~~~~~~~~~~ DB Id DB Name Inst Num Instanc ...
- oracle执行计划(二)----如何查看执行计划
目录: (一)六种执行计划 (1)explain plan for (2)set autotrace on (3)statistics_level=all (4)dbms_xplan.disp ...
- SQL Tuning 基础概述03 - 使用sql_trace和10046事件跟踪执行计划
1.使用sql_trace跟踪执行计划 1.1 当前session跟踪: alter session set sql_trace = true; //开始sql_trace alter session ...
- 通过10046 event来获取真实的执行计划
获取SQL执行计划的方式有很多,但是某些时候获取的SQL执行计划并不是准确的,只有在SQL真实执行之后获取到的SQL PLAN才是真实准确的,其他方式(如,explain plan)获取到的执行计划都 ...
- Oracle数据库查看执行计划
基于ORACLE的应用系统很多性能问题,是由应用系统SQL性能低劣引起的,所以,SQL的性能优化很重要,分析与优化SQL的性能我们一般通过查看该SQL的执行计划,本文就如何看懂执行计划,以及如何通过分 ...
- Oracle中获取执行计划的几种方法分析
以下是对Oracle中获取执行计划的几种方法进行了详细的分析介绍,需要的朋友可以参考下 1. 预估执行计划 - Explain PlanExplain plan以SQL语句作为输入,得到这条S ...
- ORACLE数据库查看执行计划的方法
一.什么是执行计划(explain plan) 执行计划:一条查询语句在ORACLE中的执行过程或访问路径的描述. 二.如何查看执行计划 1: 在PL/SQL下按F5查看执行计划.第三方工具toad等 ...
- Oracle 课程五之优化器和执行计划
课程目标 完成本课程的学习后,您应该能够: •优化器的作用 •优化器的类型 •优化器的优化步骤 •扫描的基本类型 •表连接的执行计划 •其他运算方式的执行计划 •如何看执行计划顺序 •如何获取执行计划 ...
随机推荐
- python初级(302) 6 对象(二)
一.复习 1.什么是对象 2.什么是类 3.什么是属性 4.什么是方法 5.创建一个dog类,dog的属性有颜色,方法有汪汪叫 随堂练习: class Dog: def __init__(self, ...
- matlab学习笔记12_3串联结构体,按属性创建含有元胞数组的结构体,filenames,isfield,isstruct,orderfields
一起来学matlab-matlab学习笔记12 12_3 结构体 串联结构体,按属性创建含有元胞数组的结构体,filenames,isfield,isstruct,orderfields 觉得有用的话 ...
- javafx这些学会后,开发就不难了,往tablecloumn列中添加按钮,修改javafx中tableview中tablecell中的值,修改完回车表示保存到内存中
javafx开发过程中遇见难题,往tablecloumn列中添加按钮 想了很久的方法,也配有办法判断每行中有数据的地方添加按钮set bank_caozuo.setCellFactory((col)- ...
- Bootstrap Table 初始化设置
$('#ArbetTable').bootstrapTable({ url: '/Interface/GetData', //请求后台的URL(*) method: 'get', //请求方式(*) ...
- MySQL5.7的sql脚本导入到MySQL5.5出错解决
今晚有人让我将他的数据库导入到我的mysql里,执行导入后发现有报错 想了下可能是版本的问题,询问了下,他的数据库是5.7而我的是5.5 他给我提议升级mysql版本,但是我就是不想换版本 那怎么在不 ...
- [bug]——vue 组件状态外置引发的一个 bug
背景 在编写 .vue 组件时,可以将状态外置来获取一些额外的好处,譬如有这么一个组件(global-components.vue): <template> <div> < ...
- C++ 智能指针 shared_ptr 分析
引文: C++对指针的管理提供了两种解决问题的思路: 1.不允许多个对象管理一个指针 2.允许多个对象管理一个指针,但仅当管理这个指针的最后一个对象析构时才调用delete ps:这两种思路的共同点就 ...
- [转帖]NSO到底是个什么样的公司?揭秘三叉戟0day的缔造者
NSO到底是个什么样的公司?揭秘三叉戟0day的缔造者 dawner2016-09-07共248912人围观 ,发现 3 个不明物体其他安全报告 https://www.freebuf.com/art ...
- Delphi编码与签名【URL编码与解码,Base64编码与解码,MD5加密,HMAC-SHA1、HMAC-SHA224、HMAC-SHA256、HMAC-SHA384和HMAC-SHA512签名】
作者QQ:(648437169) 点击下载➨delphi编码与签名 [Delphi编码与签名]URL编码与解码,Base64编码与解码,MD5加密,HMAC-SHA1.HMAC-SHA224.HMAC ...
- STVD使用printf输出数据错误
使用STM8L052输出调试信息 重定向put char #include "stdio.h" //必不可缺少 char putchar (char c) { /* Write a ...