11g新特性SQL执行计划管理(SQL Plan Management) (1)

数据库系统性能受到查询执行的严重影响。然而SQL语句的执行计划可能因统计信息变化,优化参数变化或方案定义变化等原因而意外改变,Oracle Optimizer优化器往往无法在没有人工干预的情况下准确进化执行计划。在无法保证新的执行计划总是趋于变得更好的情况下,用户倾向于通过存储大纲(stored outline)或锁定统计信息来保证执行计划的问题。然而使用这些方式将不可避免地丧失利用到新的优化器特性以改善SQL语句性能的优势。在保证当前可被接受执行计划的前提下,仅允许采用那些更好的,获益更多的执行计划才是终极方案。

Oracle Database 11g是在解决这一SQL执行计划上处于市场领先地位。SQL Plan Management(SPM)提供了一个完全透明且可控的执行计划进化的框架。在SPM的帮助下优化器自动管理执行计划并保证只有已知或已确认的执行计划才被采用。当一个新的计划出现时,Oracle将不会采用它,直到确认其与当前的执行计划有着相当的,或更好的性能。

SQL Plan Management(SPM)保证数据库运行时性能绝不因为执行计划的改变而大幅下降。为了确保这一点,仅仅那些已被接受的(accepted or trusted)的执行计划将被采用;任何计划的进化都将被追踪并仅在其被评价为无损于性能或有益于性能后被采纳。

SPM主要由三个部分组成:

1.执行计划基线捕捉

创建SQL执行计划基线意味着接受(或者说信任)相关SQL语句的执行计划。SQL计划基线存储在历史计划中,历史计划保存在SQL Management BASE(SMB)中,SMB位于SYSAUX表空间上。

SQL> select * from v$version; BANNER ——————————————————————————– Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 – 64bit Production PL/SQL Release 11.2.0.2.0 – Production CORE 11.2.0.2.0 Production TNS for Linux: Version 11.2.0.2.0 – Production NLSRTL Version 11.2.0.2.0 – Production . . . → Read More: 11g新特性SQL执行计划管理(SQL Plan Management) (1)

滚动游标失效(Rolling Cursor Invalidations)

在Oracle 10g中DBMS_STATS包针对GATHER_TABLE/INDEX_STATS和DELETE_TABLE/INDEX_STATS等收集统计信息的存储过程提供了AUTO_INVALIDATE选项; 该参数允许用户指定是否让那些对统计信息有依存关系的游标失效,举例来说如果SQL游标涉及到的表,索引,列或固有对象的统计信息收到以上存储过程修改时,使用NO_INVALIDATE选项可以指定是否让这些受到影响的游标失效,何时失效。 NO_INVALIDATE选项可以有以下三种值:

TRUE : 不让相关游标失效 FALSE: 立即让相关游标失效 AUTO_INVALIDATE(default):让Oracle自己决定何时让游标失效。 — no_invalidate – Do not invalide the dependent cursors if set to TRUE. — The procedure invalidates the dependent cursors immediately — if set to FALSE. — Use DBMS_STATS.AUTO_INVALIDATE to have oracle decide when to — invalidate dependend cursors. This is the default. The default . . . → Read More: 滚动游标失效(Rolling Cursor Invalidations)

10G: Using the new UTL_COMPRESS Oracle Supplied Package

Checked for relevance on 28-May-2009 PURPOSE ——- This article describes the usage of UTL_COMPRESS package. SCOPE & APPLICATION ——————- This article is intended for PL/SQL developers, engineers, or DBAs. 10G: Using the new UTL_COMPRESS Oracle Supplied Package ——————————————————- The purpose of this package is to compress/uncompress RAW, BLOB, or BFILE data. This package is . . . → Read More: 10G: Using the new UTL_COMPRESS Oracle Supplied Package

HOW TO LOAD SQL PLANS INTO SPM FROM AWR

Applies to:

Oracle Server – Enterprise Edition – Version: 10.2.0.4 to 11.2.0.0 Information in this document applies to any platform. Oracle Server Enterprise Edition – Version: 11.1.0 to 11.1.0 11.1.0.X TO 11.1.0.X

Goal The goal of the document is to provide steps for loading a sql plan into sql plan baseline from AWR. Solution

. . . → Read More: HOW TO LOAD SQL PLANS INTO SPM FROM AWR

SQL PLAN MANAGEMENT

Applies to:

Oracle Server – Enterprise Edition – Version: 11.1.0.6 to 11.2.0.2 – Release: 11.1 to 11.2 Information in this document applies to any platform. Oracle Server Enterprise Edition – Version: 11.1.0.6 to 11.2 11.1.0.X TO 11.2.0.X

Goal

SQL plan management is a preventative mechanism that records and evaluates the execution plans of SQL statements . . . → Read More: SQL PLAN MANAGEMENT

SQL PLAN MANAGEMENT TRACING

Applies to:

Oracle Server – Enterprise Edition – Version: 11.1.0.6 to 11.1.0.6 Information in this document applies to any platform. Oracle Server Enterprise Edition – Version: 11.1.0 to 11.1.0 11.1.0.X TO 11.1.0.X

Goal The goal of the document is to provide steps for tracing some of the operations of sql plan management feature. Solution connect . . . → Read More: SQL PLAN MANAGEMENT TRACING

Oracle10g: Using SQLAccess Advisor (DBMS_ADVISOR) with the Automatic Workload Repository

PURPOSE

This article is a step by step demonstration on how to use the Oracle10g SQLAccess Advisor (DBMS_ADVISOR) package to get recommendations on what Materialized Views to create in order to support a given set of queries (a workload) issued on the database. The workload is imported from the Oracle10g Automatic Workload Repository using a . . . → Read More: Oracle10g: Using SQLAccess Advisor (DBMS_ADVISOR) with the Automatic Workload Repository

HOW TO DROP PLANS FROM SPM REPOSITRY

Applies to:

Oracle Server – Enterprise Edition – Version: 11.1.0.6 to 11.1.0.6 Information in this document applies to any platform. Oracle Server Enterprise Edition – Version: 11.1.0 to 11.1.0 11.1.0.X TO 11.1.0.X

Goal

The goal of the document is to provide steps for dropping plans from SQL PLAN MANAGEMENT REPOSITRY.

Solution select sql_handle, plan_name, accepted, . . . → Read More: HOW TO DROP PLANS FROM SPM REPOSITRY