首页 » ORACLE 9i-23ai » Oracle Outline的使用

Oracle Outline的使用

昨天听一网友 feihuchina提进outline这个知识点,查了一下

A stored outline is a collection of hints associated with a specific SQL statement that allows a standard execution plan to be maintained, regardless of changes in the system environment or associated statistics. Plan stability is based on the preservation of execution plans at a point in time where the performance of a statement is considered acceptable. The outlines are stored in the OL$, OL$HINTS, and OL$NODES tables, but the [USER|ALL|DBA]_OUTLINES and [USER|ALL|DBA]_OUTLINE_HINTS views should be used to display information about existing outlines.

All of the caveats associated with optimizer hints apply equally to stored outlines. Under normal running the optimizer chooses the most suitable execution plan for the current circumstances. By using a stored outline you may be forcing the optimizer to choose a substandard execution plan, so you should monitor the affects of your stored outlines over time to make sure this isn’t happening. Remember, what works well today may not tomorrow.

总体就是说Oracle Outline是用来保持SQL执行计划(execution plan)的一个工具。我们可以保存一个时间点的执行计划,用于数据改变或系统环境改变而限制cbo,rbo强行执行原保存的执行计划,注意的是,这个执行计划现在适用随着数据的变化明天不一定是最好的。

Outline的主要使用在以下情况:
1.为避免在升级后某些sql出现严重性能下降而且在短时间内不能优化的情况,
我们可以使用outline的功能将原生产库中的sql执行计划实施在新的数据库上。

2.为避免SQL的执行计划在统计数据不准确的情况(如未能及时收集表或索引的统计信息)下导致变化从而引起的性能降低。
3.避免大规模分布实施的应用出现数据库版本、配置等区别引起的优化器产生不同的执行计划。
4.某些Bug引起优化器生成较差的执行计划。在bug修复前我们可以使用outline来强制SQL的执行计划的正确。

Outline的机制是将所需要的执行计划的hint保存在outline的表中。当执行SQL时,Oracle会与outline中的SQL比较,如果该SQL有保存的outline,则通过保存的hint生成执行计划。

Outlines can be generated for specific statements using the CREATE OUTLINE statement or the DBMS_OUTLN.CREATE_OUTLINE procedure,uses the DBMS_OUTLN.CREATE_OUTLINE procedure to create an outline

查询

SELECT name, category, used FROM user_outlines;
打赏

目前这篇文章有1条评论(Rss)评论关闭。

  1. Adrien Bayani | #1
    2011-12-21 at 06:03

    Oh my goodness! a tremendous article dude. Thank you However I’m experiencing issue with ur rss . Don’t know why Unable to subscribe to it. Is there anyone getting an identical rss drawback? Anyone who knows kindly respond. Thnkx