Upload
james-tong
View
1.518
Download
0
Embed Size (px)
DESCRIPTION
oracle performance tuning methodology . the key is to find and solve contention.
Citation preview
ORACLE 性能优化
童家旺微博: jametong
博客: dbthink.com
大纲
优化是什么? Latency & Throughput
Performance & Scalability
数据库的 Tuning By Layers
常见案例分析 参考资料
优化是什么?
The fastest way to do something is don‘t do it Anonymous
Two ways to improve performance, do it less or
do it faster Anonymous
Performance is all about code path From Cary Millsap
http://carymillsap.blogspot.com/2010/09/my-otn-interview-at-oow2010-
which-hasnt.html
优化是什么?
不访问不必要的数据
合理的利用硬件来提升访问效率 使用缓存消除对数据的重复访问
使用批量处理来减少交互次数(磁盘、网络)
使用新硬件来降低后端的延时,提高效率
提高系统的吞吐量 对工作单元进行细化,减少串行操作
合理的拆分(水平、垂直拆分)以提高系统的整体吞吐能力
响应时间 Vs 吞吐量
Performance & Scalability
系统是否足够快? 只有一个用户时足够
快吗? 那么系统有扩展性问
题,而不是性能问题? 排队论可以解释高负
载情况下的性能问题。
Tuning By Layers (逐层优化)
Design Layer
Application Layer
请求次数、网络交互
Database Code Layer
SQL Parse 、 SQL Tuning 、 Locks 、 Concurrency
Memory Layer
Buffer Cache 、 PGA 、 Shared Pool
Disk Layer
不同的硬件设备
合理设计表结构
动静分离 冷热分离 大字段分离 重要程度分离 合理选择范式化
业务层缓存优化 使用场景
缓存的一致性维护问题 数据的具体读写比 变更频率 业务对一致性的要求 使用何种缓存方式 .
注意事项 考虑缓存的刷新策略 考虑缓存的数据延迟对业务的影响 考虑缓存失效时 , 系统的支撑能力 参考缓存工具 : MemCached, Tair, Redis
Oracle 自身的 Server Result Cache 、 Client Result Cache 、 Mview
批量处理 使用匿名块包装多次 SQL 批量数据处理( Array Fetch 、 Array
Insert )
2 4 8 12 16 20 24 28 32 36 40 50 60 100
150
200
400
800
1600
3200
5000
0
2
4
6
8
10
12
14
16
elapsed time
使用绑定变量
0 1 2 3 4 5 6 70
10000
20000
30000
40000
50000
60000
70000
80000
90000
Parse Once Execute Many Session Cache Cursor Bind VariableNo Bind Variable
索引优化
优化系统争用
减少 Contention
Index Concurrency 高插入频率的单调递增索引
Row Concurrency 高更新次数的记录
Buffer Contention 队列表的处理
Mutex Contention 高执行次数的 SQL
LGWR 的优化
硬件优化
使用 BBU 或 Shared Storage 优化日志写 使用 Flash 优化数据文件读写 使用 IB 优化 RAC 的 InterConnect
使用高频 CPU 以及超频技术提高 CPU 能力
Recommended Reading
Optimizing Oracle Performance By Cary Millsap, Jeff Holt
Forecasting Oracle Performance By Craig Shallahamer
Guerrilla Capacity Planning By Neil J. Gunther
Relational Database Index Design and the Optimizers By Tapio Lahdenmaki
Think Clearly About Performance By Cary Millsap http://www.method-r.com/downloads/doc_details/44-thinking-clearly-about-performance
TroubleShooting Oracle Performance By Christian Antognini
Oracle 性能优化生存指南 Translated By 郑勇斌 / 胡怡文 / 童家旺
性能诊断艺术 Translated By 冯大辉 / 胡怡文 / 童家旺