Sql Statement Turing part2

本文介绍了SQL执行计划的概念及其对数据库性能的影响,包括如何使用提示(Hints)来稳定执行计划,以及通过SQL Plan Management等工具进行性能调优的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hint的语法可以查联机文档的SQL reference


SELECT /*+ First_rows */ * FROM hr.employees;
SELECT /*+ ALL_ROWS */ * FROM hr.employees;


上面两个hint对应最佳response time与最佳thoughout。


Optimizer Plan Stability(稳定性)


同一个SQL语句在不同版本不同环境下,可能执行计划就不


同,从而导致性能不同。


Users can stabilize execution plans,to force


applications to use a desired SQL access path.
用户能强制稳定地使用某个执行计划。


A consistent execution path is thereby maintained


through database changes.


This is done by creating a stored outline consisting


of hints.(过时了,9i开始用了sql plan management代替


了)


The OPTIMIZER_FEATURES_ENABLE parameter enables the


optimizer to retain CBO features of previous


versions.
指定某个过去的版本号,就可以用过去版本的特性来运行这


个SQL语句。


alter system set OPTIMIZER_FEATURES_ENABLE=8.1.5


scope=spfile;


SQL Plan Management(9i开始取代了Stored outlines)


Diagnostic Tools诊断工具


*Statspack综合性报告
*EXPLAIN PLAN
*SQL trace and TKPROF(TKPROF是个解读trace文件的工具



*SQL*Plus autotrace feature
*Oracle SQL Analyze(OEM中的功能)


SQL Reports in Statspack
SQL语句排行榜
SQL ordered by gets (读取buffer cache次


数最多的排行榜)
SQL ordered by reads (从磁盘上读的块到内


存里的数量的语句排行榜)
SQL ordered by executions (执行次数最多的


SQL的排行榜)
SQL ordered by parse calls (library cache中


的解析次数的排序)


如果性能不佳,将前几名的SQL语句进行调整,可能就得到


提高。OEM中也能展现出TOP SQL。


Execution Plan
An execution plan is a set of steps that the


optimizer performs when executing a SQL statement


and performing an operation.


Viewing Execution Plan
EXPLAN PLAN
SQL Trace
Automatic Workload Repository
V$SQL_PLAN
SQL*Plus AUTOTRACE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值