场景5 Performance Management

性能调优(不能重启数据库)

索引

资源管理器

性能优化

统计分析

SQL性能分析

SPM (SQL执行计划管理)

堆表 :数据存储无序

位图索引 :适合字段重复值高的,数据仓库环境下(适合OLAP/DSS环境),存储占用空间少, DML成本高, WHERE中与或操作效率高

eg :

select count(*) from customers where m_status = married and region in (‘central’, ‘west’);

eg :

su -oracle

sqlplus / as sysdba

set linesize 120

set pagesize 20

line on

timing on

sqlprompt ‘_user@_connect_identifier’

start up

alter user scott identified by tiger unlock;

conn scott/tiger

create table t1 (id number, color varchar2, pty number);

begin for i in 1..50000 loop insert into t1 values(1, blue’, 1000); end loop; commt; end; /

select count(*) from t1;

update t1 set color=‘red’ where id < 20001;

update t1 set color=‘green’ where id > 40000;

commit;

select distinct color from t1;

!clear

create tablespace indx datafile ‘/u01/app/oracle/prod/indx01.dbf’ size 100m;

create indext1_color_ind on t1(color) tablespace indx;

analyze table t1 compute statistics; (表分析)

analyze index t1_color_ind compute statistics;

select a.table_name, a.index_name, a.index_type, a.leef_blocks, b.height from user_indexes a.index_stats b where a.index_mane=b.index_name and a.index_name=’T1_COLOR_IND’;

col table_name for a10

col index_name for a10

@?sqlplus/

conn scott/tiger

set autrace trace

select count(*) from t1 where color=‘blue’;

set auto trace off

select * from t1 where id<10;

drop index t1_color_indx;

create bitmap index t1_color_indx on t1(color) tablespace indx;

analyze index t1_color_indx compute statistics;

analyze index t1_color_indx valudate structure;

select a.table_name, a.index_name, a.index_type, a.leef_blocks, b.height from user_indexes a.index_stats b where a.index_mane=b.index_name and a.index_name=’T1_COLOR_IND’;

set autostrade trace

select count(*) from t1 where color=‘red’;

set auto trace off

select * from  t1 where id < 10;

update t1 set color = ‘blue’ where id = 1;

update t1 set color = ‘green’ where id = 2;(打开另一个会话)

rollback;

rollback;

set autotrace trace

select count(*) from t1 where color=‘red’ or color = ‘blue’;

su - oracle

|sql

e.g. : select rowid, ename, sal from emp;

rowid : 6 :object_id, 3 :file#, 6 :block, 3 : row#

复合压缩索引 :

全局hash索引 :

反向索引 :解决热块问题,不适合范围查询

平衡树索引(普通索引):适合字段基数大,重复值少,DML代价比较低,适合OLTP环境

经常用于select语句中,where语句中,排序的字段适合建立索引

表级共享锁 share lock

行级排他锁 exclusive lock

段级位图锁

eg :

show parameter cpu

show parameter resoure

eg 资源管理器的创建 :

官方文档 :administrator

SQL 语句执行的三个过程 :

parse解析 : 建立执行计划

execute执行 :

fetch取值从buffer cache里获取数据 :

硬解析 :三步

软解析 :

1. 在lib cache读取执行计划

2. execute plan

3. 从buffer cache读取数据块

LRU : 最近最少使用

eg :

alter system set result_cache_max_size=0;

show parameter result

alter system set result_cache_max_size=1536;(从0改为非0后,必须重启才能生效)

eg :

conn scott/tiger

select /*+ result_cache */ count(*) from emp;

set autotrace trace

r

r

1

show parameter result

alter system set result_cache_mode = force;

select /*+ result_cache */ count(*) from emp;

r

exec dbms_result_cache.flush;

r

r

select dbms_result_cache.status from dual;

shutdown immediate;

startup

select dbms_result_cache.status from dual;

show parameter result

alter system set result_cache_mode=manual;

conn scott/tiger

set autotrace trace

select count(*) from emp where empno=20;

select /*+ result_cache */ count(*) from emp where deptno=20;

exec dbms_result_cache.memory_report;

set serverout on

exec dbms_result_cache.memory_report;

eg :

select * from emp where deptno=:n;

结果缓存(官方文档 Performance Tuning Guide 7.6 Managing the server and client query cache)

统计分析 (官方文档 PL/SQL Package and Type Reference 或

SPA (SQL Performance Analyzer)

SQL性能优化分析

SPM(SQL Plan Management)

SQL执行计划管理

store outline 存储纲要

sql profile

hints 提示

稳定执行计划,根据访问对象的变化,实时调整新的计划

spm : sql执行计划管理

sql plan baseline : 执行计划基线(执行计划的集合)

eg :

show parameter optimizer

eg :

select * from tab;

create table emp1 select * from emp;

select * from emp1;

set autotrace on

select * from emp1 where empno=7788;

r

select sql_text, sql_id from v$sql where sql_text like ‘select * from emp%’; (查询sql id)

set serveroutput on

declare

`1_plans_loaded pls_integer;

begin

1_p;ans_loaded := DBMS_SPM.load_plans_from_cursor_cache(sql_id =>…);

DBMS_OUTPUT.put_line(‘Plans Loaded : || 1_plan_loaded);

end;

/

select sql_handle, plan_name, enabled, accepted from dba_sql_plan_baselines where sql_text like ‘%emp1%’ and sql_id not like ‘%dba%’ ;

create index

set autotrace on

select * from emp1 where empno = 7788;

场景5 Performance Management的更多相关文章

  1. 场景3 Data Management

    场景3 Data Management 数据管理 性能优化 OLTP OLAP 物化视图 :表的快照 传输表空间 :异构平台的数据迁移 星型转换 :事实表 OLTP : 在线事务处理 1. trans ...

  2. Pinpoint是一个开源的 APM (Application Performance Management/应用性能管理)工具,用于基于java的大规模分布式系统,基于Google Dapper论文

    Pinpoint是一个开源的 APM (Application Performance Management/应用性能管理)工具,用于基于java的大规模分布式系统,基于Google Dapper论文 ...

  3. puma vs passenger vs rainbows! vs unicorn vs thin 适用场景 及 performance

    ruby的几个web server,按照开发活跃度.并发方案及要点.适用场景等分析puma vs passenger vs rainbows! vs unicorn vs thin. 1. thin: ...

  4. 应用性能管理(APM, Application Performance Management)

    当下成熟的互联网公司都建立有从基础设施到应用程序的全方位监控系统,力求及时发现故障进行处理并为优化程序提供性能数据支持,降低整体运维成本.国内外商业的APM有Compuware.iMaster.博睿B ...

  5. 独立安装Oracle Hyperion Enterprise Performance Management 验证过程

    在安装EPM的过程中,都是安装既定的操作手册进行,只是一个过程的重复,对自己安装不会留下深刻的印象.根据自己学习体会,制定安装步骤,去验证自己学习过程中的体会,加深学习印象,解决安装中遇到的问题,模仿 ...

  6. Thinking Clearly about Performance

    http://queue.acm.org/detail.cfm?id=1854041 The July/August issue of acmqueue is out now acmqueue is ...

  7. Java Performance Optimization Tools and Techniques for Turbocharged Apps--reference

    Java Performance Optimization by: Pierre-Hugues Charbonneau reference:http://refcardz.dzone.com/refc ...

  8. Magic Quadrant for Security Information and Event Management

    https://www.gartner.com/doc/reprints?id=1-4LC8PAW&ct=171130&st=sb Summary Security and risk ...

  9. 一篇分析诊断被&quot;hang&quot;住数据库的资料(Oracle Performance Diagnostic Guide——Hang/Locking)

    该资料已上传至本人QQ群空间,如需该资料,可到本人QQ群空间查找.下面贴表文本: Oracle Performance Diagnostic GuideHang/LockingVersion 3.1. ...

随机推荐

  1. Linux系统下安装Mysql

    原文档地址:http://www.itpub.net/thread-1766546-1-1.html 1.在Linux服务器上通过wget命令取得rpm包: wget –c http://dev.my ...

  2. Mac 安装 MySQL

    在 Mac 下用 Homebrew 安装 MySQL, 网上的教程倒是很多,不过大多数都很默契地雷同.如果稍有点定制要求,就无从下手了. 我先也不免俗,从基本的开始: 一.首先安装 Homebrew ...

  3. Android之Toolbar的三个问题:修改左边箭头颜色、怎样修改右边以及子activity中的toolbar添加返回箭头

    1)怎样修改左边这个小箭头的颜色? 2)怎样修改右边这三个点的颜色.怎样把这三个点替换成我自己的图标? 3)怎样让"交易清单"这4个字居中显示? 首先设置Theme为AppComp ...

  4. [官方作品] 关于ES4的设首页问题

    [官方作品] 关于ES4的设首页问题 Skyfree 发表于 2013-2-10 21:55:03 https://www.itsk.com/thread-254503-1-1.html 关于ES4设 ...

  5. [ubuntu]用ubuntu开发的日子----win7 ubuntu双系统

    小子终于忍不了win7某些蛋疼的设定,看群里好多大牛推荐mac,但资金紧张,只好推而求其次使用ubuntu,但是由于公司工作环境是windows,所以还必须保留windows系统,一次决定双系统. 下 ...

  6. linux的帮助信息获取以及man章节的划分

    linux的帮助信息获取以及man章节的划分 linux 帮助 man 章节 linux 获取帮助的途径 (1)help (2)man (3)info command在线获取 (4)程序自带帮助文档 ...

  7. Centos启动Cassandra交互模式失败:No appropriate python interpreter found

    在CentOS6.5安装好Cassandra后,启动交互模式: bin/sqlsh 192.168.10.154 时,报错 No appropriate python interpreter foun ...

  8. 基础算法之快速排序Quick Sort

    原理 快速排序(Quicksort)是对冒泡排序的一种改进. 从数列中挑出一个元素,称为"基准"(pivot); 排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的 ...

  9. xcode报错http

    问题: Xcode项目发送网络请求时,报错:“App Transport Security has blocked a cleartext HTTP (http://) resource load s ...

  10. 关于c#调用java中间件api的几个问题

    由于项目需要,做的c#客户端数据库连接串首先肯定不能写死的程序里(数据库很容易被攻击,我们的项目半年改了几次密码...) 放置在配置文件内,都可以看得到,最开始想法将配置文件加密,老师说加密过的文件还 ...