[20181225]12CR2 SQL Plan Directives.txt

--//12C引入SQL PLAN Directives.12cR1版本会造成大量的动态取样,影响性能.许多人把OPTIMIZER_ADAPTIVE_FEATURES设置为false.
--//这也是为什么我不主张将XX.1版本使用在生产系统.12CR2做了一些改进,废除了OPTIMIZER_ADAPTIVE_FEATURES参数.使用2个新的
--//参数OPTIMIZER_ADAPTIVE_PLANS,OPTIMIZER_ADAPTIVE_STATISTICS,缺省前者true,后者为false.
--//通过测试说明问题.

1.环境:
SCOTT@test01p> @ ver1
PORT_STRING          VERSION    BANNER                                                                               CON_ID
-------------------- ---------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.2.0.1.0 Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

SCOTT@test01p> show parameter OPTIMIZER_ADAPTIVE
NAME                              TYPE    VALUE
--------------------------------- ------- ------
optimizer_adaptive_plans          boolean TRUE
optimizer_adaptive_reporting_only boolean FALSE
optimizer_adaptive_statistics     boolean FALSE

--//注:没有OPTIMIZER_ADAPTIVE_FEATURES参数,optimizer_adaptive_plans=true,optimizer_adaptive_statistics=false.

2.建立测试环境:
CREATE TABLE t
AS
       SELECT ROWNUM id
             ,LPAD ('x', 20, 'x') name
             ,MOD (ROWNUM, 3) flag1
             ,MOD (ROWNUM, 3) flag2
             ,MOD (ROWNUM, 3) flag3
         FROM DUAL
   CONNECT BY LEVEL <= 1e5;

--//说明:flags1,flags2,flags3分别存在3个取值,按照道理存在27种选择.因为存在相关性,仅仅存在3种选择.

3.测试:
SCOTT@test01p> alter session set statistics_level=all;
Session altered.

SCOTT@test01p> select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1;
COUNT(DISTINCTNAME)
-------------------
                  1

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  872fdta99gdk8, child number 0
-------------------------------------
select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
Plan hash value: 2359337548
---------------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation            | Name     | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
---------------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |      1 |        |       |   155 (100)|          |      1 |00:00:00.06 |     556 |    540 |       |       |          |
|   1 |  SORT AGGREGATE      |          |      1 |      1 |    12 |            |          |      1 |00:00:00.06 |     556 |    540 |       |       |          |
|   2 |   VIEW               | VW_DAG_0 |      1 |      1 |    12 |   155   (2)| 00:00:01 |      1 |00:00:00.06 |     556 |    540 |       |       |          |
|   3 |    HASH GROUP BY     |          |      1 |      1 |    30 |   155   (2)| 00:00:01 |      1 |00:00:00.06 |     556 |    540 |  1345K|  1345K|  504K (0)|
|*  4 |     TABLE ACCESS FULL| T        |      1 |   3704 |   108K|   154   (1)| 00:00:01 |  33334 |00:00:00.06 |     556 |    540 |       |       |          |
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$C33C846D
   2 - SEL$5771D262 / VW_DAG_0@SEL$C33C846D
   3 - SEL$5771D262
   4 - SEL$5771D262 / T@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   4 - filter(("FLAG1"=1 AND "FLAG2"=1 AND "FLAG3"=1))

--//注意看id=4, E-Rows=3704,估算按照100000/27 = 3703.7,而A-Rows=33334(10000/3 = 3333.3),存在很大偏差.

SCOTT@test01p> select sql_id,child_number,is_reoptimizable  from v$sql  where sql_id ='872fdta99gdk8';
SQL_ID        CHILD_NUMBER I
------------- ------------ -
872fdta99gdk8            0 Y
--//is_reoptimizable='Y'

SCOTT@test01p> exec dbms_spd.flush_sql_plan_directive;
PL/SQL procedure successfully completed.

set numw 20
column NOTES format a50

SELECT directive_id
      ,TYPE
      ,enabled
      ,state
      ,notes
      ,reason
  FROM dba_sql_plan_directives
 WHERE directive_id IN (SELECT directive_id
                          FROM dba_sql_plan_dir_objects
                         WHERE owner = USER AND object_name = 'T');

DIRECTIVE_ID TYPE                 ENA STATE                NOTES                                              REASON
-------------------- -------------------- --- -------------------- -------------------------------------------------- ------------------------------------
17342821566768621333 DYNAMIC_SAMPLING     YES USABLE               <spd_note><internal_state>NEW</internal_state><red SINGLE TABLE CARDINALITY MISESTIMATE
                                                                   undant>NO</redundant><spd_text>{EC(SCOTT.T)[FLAG1,
                                                                    FLAG2, FLAG3]}</spd_text></spd_note>
--//指导建议字段flag1,flag2,flag3联合查询时存在偏差,建议动态取样.
--//补充说明:{EC(SCOTT.T)[FLAG1,FLAG2, FLAG3]}
--//这里的E和C,以及可能出现其他的字符,解释如下:
E – equality_predicates_only
C – simple_column_predicates_only
J – index_access_by_join_predicates
F – filter_on_joining_object

--//再次执行:

SCOTT@test01p> select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1;
COUNT(DISTINCTNAME)
-------------------
                  1

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  872fdta99gdk8, child number 1
-------------------------------------
select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
Plan hash value: 2359337548
------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation            | Name     | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |      1 |        |       |   156 (100)|          |      1 |00:00:00.01 |     556 |       |       |          |
|   1 |  SORT AGGREGATE      |          |      1 |      1 |    12 |            |          |      1 |00:00:00.01 |     556 |       |       |          |
|   2 |   VIEW               | VW_DAG_0 |      1 |      1 |    12 |   156   (2)| 00:00:01 |      1 |00:00:00.01 |     556 |       |       |          |
|   3 |    HASH GROUP BY     |          |      1 |      1 |    30 |   156   (2)| 00:00:01 |      1 |00:00:00.01 |     556 |  1345K|  1345K|  505K (0)|
|*  4 |     TABLE ACCESS FULL| T        |      1 |  33334 |   976K|   154   (1)| 00:00:01 |  33334 |00:00:00.01 |     556 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$C33C846D
   2 - SEL$5771D262 / VW_DAG_0@SEL$C33C846D
   3 - SEL$5771D262
   4 - SEL$5771D262 / T@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   4 - filter(("FLAG1"=1 AND "FLAG2"=1 AND "FLAG3"=1))
Note
-----
   - statistics feedback used for this statement
--//注意note,指示statistics feedback used for this statement.

SCOTT@test01p> select sql_id,child_number,is_reoptimizable  from v$sql  where sql_id ='872fdta99gdk8';
SQL_ID                CHILD_NUMBER I
------------- -------------------- -
872fdta99gdk8                    0 Y
872fdta99gdk8                    1 N

SCOTT@test01p> @ share 872fdta99gdk8
SQL_TEXT                       = select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
SQL_ID                         = 872fdta99gdk8
ADDRESS                        = 000007FF1393F830
CHILD_ADDRESS                  = 000007FF13D9C198
CHILD_NUMBER                   = 0
USE_FEEDBACK_STATS             = Y
REASON                         = <ChildNode><ChildNumber>0</ChildNumber><ID>48</ID><reason>Auto Reoptimization Mismatch(1)</reason><size>3x4</size><kxscflg>32</kxscflg><kxscfl4>4194560</kxscfl4><dnum_kksfcxe>0</dnum_kksfcxe></ChildNode>
--------------------------------------------------
SQL_TEXT                       = select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
SQL_ID                         = 872fdta99gdk8
ADDRESS                        = 000007FF1393F830
CHILD_ADDRESS                  = 000007FF115A7E58
CHILD_NUMBER                   = 1
REASON                         =
--------------------------------------------------
PL/SQL procedure successfully completed.

SELECT directive_id
      ,TYPE
      ,enabled
      ,state
      ,notes
      ,reason
  FROM dba_sql_plan_directives
 WHERE directive_id IN (SELECT directive_id
                          FROM dba_sql_plan_dir_objects
                         WHERE owner = USER AND object_name = 'T');

DIRECTIVE_ID TYPE                 ENA STATE                NOTES                                              REASON
-------------------- -------------------- --- -------------------- -------------------------------------------------- ------------------------------------
17342821566768621333 DYNAMIC_SAMPLING     YES USABLE               <spd_note><internal_state>NEW</internal_state><red SINGLE TABLE CARDINALITY MISESTIMATE
                                                                   undant>NO</redundant><spd_text>{EC(SCOTT.T)[FLAG1,
                                                                    FLAG2, FLAG3]}</spd_text></spd_note>

4.继续测试:
--//设置OPTIMIZER_ADAPTIVE_STATISTICS=true看看.
SCOTT@test01p> alter session set OPTIMIZER_ADAPTIVE_STATISTICS=true ;
Session altered.

SCOTT@test01p> select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1;
COUNT(DISTINCTNAME)
-------------------
                  1

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  872fdta99gdk8, child number 2
-------------------------------------
select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
Plan hash value: 2359337548
------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation            | Name     | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |      1 |        |       |   157 (100)|          |      1 |00:00:00.01 |     556 |       |       |          |
|   1 |  SORT AGGREGATE      |          |      1 |      1 |    12 |            |          |      1 |00:00:00.01 |     556 |       |       |          |
|   2 |   VIEW               | VW_DAG_0 |      1 |      1 |    12 |   157   (3)| 00:00:01 |      1 |00:00:00.01 |     556 |       |       |          |
|   3 |    HASH GROUP BY     |          |      1 |      1 |    30 |   157   (3)| 00:00:01 |      1 |00:00:00.01 |     556 |  1345K|  1345K|  496K (0)|
|*  4 |     TABLE ACCESS FULL| T        |      1 |  48497 |  1420K|   154   (1)| 00:00:01 |  33334 |00:00:00.01 |     556 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$C33C846D
   2 - SEL$5771D262 / VW_DAG_0@SEL$C33C846D
   3 - SEL$5771D262
   4 - SEL$5771D262 / T@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   4 - filter(("FLAG1"=1 AND "FLAG2"=1 AND "FLAG3"=1))
Note
-----
   - dynamic statistics used: dynamic sampling (level=2)
   - 1 Sql Plan Directive used for this statement

--//设置OPTIMIZER_ADAPTIVE_STATISTICS=true的情况下,做了动态取样(level=2).产生新的子光标.

SCOTT@test01p> select sql_id,child_number,is_reoptimizable  from v$sql  where sql_id ='872fdta99gdk8';
SQL_ID                CHILD_NUMBER I
------------- -------------------- -
872fdta99gdk8                    0 Y
872fdta99gdk8                    1 N
872fdta99gdk8                    2 N

SCOTT@test01p> @ share 872fdta99gdk8
old  15:           and q.sql_id like ''&1''',
new  15:           and q.sql_id like ''872fdta99gdk8''',
SQL_TEXT                       = select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
SQL_ID                         = 872fdta99gdk8
ADDRESS                        = 000007FF1393F830
CHILD_ADDRESS                  = 000007FF13D9C198
CHILD_NUMBER                   = 0
USE_FEEDBACK_STATS             = Y
REASON                         = <ChildNode><ChildNumber>0</ChildNumber><ID>48</ID><reason>Auto Reoptimization Mismatch(1)</reason><size>3x4</size><kxscflg>32</kxscflg><kxscfl4>4194560</kxscfl4><dnum_kksfcxe>0</dnum_kksfcxe></ChildNode>
--------------------------------------------------
SQL_TEXT                       = select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
SQL_ID                         = 872fdta99gdk8
ADDRESS                        = 000007FF1393F830
CHILD_ADDRESS                  = 000007FF115A7E58
CHILD_NUMBER                   = 1
REASON                         = <ChildNode><ChildNumber>1</ChildNumber><ID>3</ID><reason>Optimizer mismatch(12)</reason><size>2x440</size><_optimizer_dsdir_usage_control> 0                    126                 </_optimizer_dsdir_usage_control><optimizer_adaptive_stat
istics> false
true                </optimizer_adaptive_statistics><_optimizer_use_feedback_for_join> false                true                </_optimizer_use_feedback_for_join><_optimizer_ads_for_pq> false                true                </_optimizer_ads_for_pq></ChildNode>
--------------------------------------------------
SQL_TEXT                       = select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
SQL_ID                         = 872fdta99gdk8
ADDRESS                        = 000007FF1393F830
CHILD_ADDRESS                  = 000007FF0FDBE618
CHILD_NUMBER                   = 2
OPTIMIZER_MISMATCH             = Y
REASON                         =
--------------------------------------------------

SCOTT@test01p> exec dbms_spd.flush_sql_plan_directive;
PL/SQL procedure successfully completed.

SELECT directive_id
      ,TYPE
      ,enabled
      ,state
      ,notes
      ,reason
  FROM dba_sql_plan_directives
 WHERE directive_id IN (SELECT directive_id
                          FROM dba_sql_plan_dir_objects
                         WHERE owner = USER AND object_name = 'T');

DIRECTIVE_ID TYPE                 ENA STATE  NOTES                                              REASON
-------------------- -------------------- --- ------ -------------------------------------------------- ------------------------------------
14350253949522184195 DYNAMIC_SAMPLING_RES YES USABLE <spd_note><internal_state>NEW</internal_state><red VERIFY CARDINALITY ESTIMATE
                     ULT                             undant>NO</redundant><spd_text>{(SCOTT.T, num_rows
                                                     =100000) - (SQL_ID:4k5yrxfcvd5qb, T.CARD=48497[-2
                                                     -2])}</spd_text></spd_note>

17342821566768621333 DYNAMIC_SAMPLING     YES USABLE <spd_note><internal_state>MISSING_STATS</internal_ SINGLE TABLE CARDINALITY MISESTIMATE
                                                     state><redundant>NO</redundant><spd_text>{EC(SCOTT
                                                     .T)[FLAG1, FLAG2, FLAG3]}</spd_text></spd_note>

--//多了一行,动态取样分析后估计T.CARD=48497,虽然与实际A-Rows=33334还是存在很大偏差.指导提示是MISSING_STATS.
--//补充说明SQL_ID:4k5yrxfcvd5qb,我没有查询到对于sql语句,有点奇怪!!

SCOTT@test01p> exec dbms_stats.gather_table_stats(user,'T',options=>'gather auto',no_invalidate=>false);
PL/SQL procedure successfully completed.

SCOTT@test01p> select column_name,num_buckets,histogram from user_tab_col_statistics where table_name ='T';
COLUMN_NAME NUM_BUCKETS HISTOGRAM
----------- ----------- ---------------
ID                    1 NONE
NAME                  1 NONE
FLAG1                 3 FREQUENCY
FLAG2                 3 FREQUENCY
FLAG3                 3 FREQUENCY

--//并没有指导建议生成相关列的统计信息.
--//实际上12cR2引入新参数AUTO_STAT_EXTENSIONS控制extended stats的收集,缺省设置off.(没有打开).设置AUTO_STAT_EXTENSIONS=on可以打开.
SCOTT@test01p> select dbms_stats.get_prefs('AUTO_STAT_EXTENSIONS') c10 from dual;
C10
----------
OFF

SCOTT@test01p> exec dbms_stats.set_global_prefs('AUTO_STAT_EXTENSIONS','ON') ;
PL/SQL procedure successfully completed.

SCOTT@test01p> select dbms_stats.get_prefs('AUTO_STAT_EXTENSIONS') c10 from dual;
C10
----------
ON

SCOTT@test01p> exec dbms_stats.gather_table_stats(user,'T',options=>'gather auto',no_invalidate=>false);
PL/SQL procedure successfully completed.

SCOTT@test01p> column COLUMN_NAME format a30
SCOTT@test01p> select column_name,num_buckets,histogram from user_tab_col_statistics where table_name ='T';
COLUMN_NAME                    NUM_BUCKETS HISTOGRAM
------------------------------ ----------- ---------------
ID                                       1 NONE
NAME                                     1 NONE
FLAG1                                    3 FREQUENCY
FLAG2                                    3 FREQUENCY
FLAG3                                    3 FREQUENCY
SYS_STS0SR$HPC$E#KVDPEN#0R2JOU           3 FREQUENCY
6 rows selected.

SCOTT@test01p> column EXTENSION_name format a30
SCOTT@test01p> select * from user_stat_extensions where table_name ='T';
TABLE_NAME EXTENSION_NAME                 EXTENSION                 CREATOR DRO
---------- ------------------------------ ------------------------- ------- ---
T          SYS_STS0SR$HPC$E#KVDPEN#0R2JOU ("FLAG1","FLAG2","FLAG3") SYSTEM  YES

--//可以发现现在收集了相关列("FLAG1","FLAG2","FLAG3")的统计,并且建立了直方图.

SCOTT@test01p> alter session set OPTIMIZER_ADAPTIVE_STATISTICS=false ;
Session altered.

SCOTT@test01p> select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1;
COUNT(DISTINCTNAME)
-------------------
                  1

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  872fdta99gdk8, child number 1
-------------------------------------
select count(distinct name) from t where flag1=1 and flag2=1 and flag3=1
Plan hash value: 2359337548
------------------------------------------------------------------------------------------------------------------------------------------------------
| Id  | Operation            | Name     | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |  OMem |  1Mem | Used-Mem |
------------------------------------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT     |          |      1 |        |       |   156 (100)|          |      1 |00:00:00.01 |     556 |       |       |          |
|   1 |  SORT AGGREGATE      |          |      1 |      1 |    12 |            |          |      1 |00:00:00.01 |     556 |       |       |          |
|   2 |   VIEW               | VW_DAG_0 |      1 |      1 |    12 |   156   (2)| 00:00:01 |      1 |00:00:00.01 |     556 |       |       |          |
|   3 |    HASH GROUP BY     |          |      1 |      1 |    30 |   156   (2)| 00:00:01 |      1 |00:00:00.01 |     556 |  1345K|  1345K|  507K (0)|
|*  4 |     TABLE ACCESS FULL| T        |      1 |  33334 |   976K|   154   (1)| 00:00:01 |  33334 |00:00:00.01 |     556 |       |       |          |
------------------------------------------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$C33C846D
   2 - SEL$5771D262 / VW_DAG_0@SEL$C33C846D
   3 - SEL$5771D262
   4 - SEL$5771D262 / T@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   4 - filter(("FLAG1"=1 AND "FLAG2"=1 AND "FLAG3"=1))

--//可以发现E-Rows已经正确修正.

SCOTT@test01p> exec dbms_spd.flush_sql_plan_directive;
PL/SQL procedure successfully completed.

DIRECTIVE_ID TYPE                 ENA STATE                NOTES                                              REASON
-------------------- -------------------- --- -------------------- -------------------------------------------------- ------------------------------------
14350253949522184195 DYNAMIC_SAMPLING_RES YES USABLE               <spd_note><internal_state>NEW</internal_state><red VERIFY CARDINALITY ESTIMATE
                     ULT                                           undant>NO</redundant><spd_text>{(SCOTT.T, num_rows
                                                                   =100000) - (SQL_ID:4k5yrxfcvd5qb, T.CARD=48497[-2
                                                                   -2])}</spd_text></spd_note>

17342821566768621333 DYNAMIC_SAMPLING     YES SUPERSEDED           <spd_note><internal_state>HAS_STATS</internal_stat SINGLE TABLE CARDINALITY MISESTIMATE
                                                                   e><redundant>NO</redundant><spd_text>{EC(SCOTT.T)[
                                                                   FLAG1, FLAG2, FLAG3]}</spd_text></spd_note>

--//注意看现在不是MISSING_STATS而是提示HAS_STATS.   SUPERSEDED 表示 取代,接替.
--//有了相关列统计其它涉及相关列的查询就不会在动态取样,而是估计行数与实际行数接近.而且执行其它类似语句也不会出现is_reoptimizable='Y'的情况.

SCOTT@test01p> select max(id) from t where flag1=1 and flag2=1 and flag3=1;
   MAX(ID)
----------
    100000

SCOTT@test01p> @ dpc '' ''
PLAN_TABLE_OUTPUT
-------------------------------------
SQL_ID  6stmvx0gcybbg, child number 0
-------------------------------------
select max(id) from t where flag1=1 and flag2=1 and flag3=1
Plan hash value: 2966233522
---------------------------------------------------------------------------------------------------------------------
| Id  | Operation          | Name | Starts | E-Rows |E-Bytes| Cost (%CPU)| E-Time   | A-Rows |   A-Time   | Buffers |
---------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |      1 |        |       |   154 (100)|          |      1 |00:00:00.01 |     556 |
|   1 |  SORT AGGREGATE    |      |      1 |      1 |    14 |            |          |      1 |00:00:00.01 |     556 |
|*  2 |   TABLE ACCESS FULL| T    |      1 |  33334 |   455K|   154   (1)| 00:00:01 |  33334 |00:00:00.01 |     556 |
---------------------------------------------------------------------------------------------------------------------
Query Block Name / Object Alias (identified by operation id):
-------------------------------------------------------------
   1 - SEL$1
   2 - SEL$1 / T@SEL$1
Predicate Information (identified by operation id):
---------------------------------------------------
   2 - filter(("FLAG1"=1 AND "FLAG2"=1 AND "FLAG3"=1))

SCOTT@test01p> select sql_id,child_number,is_reoptimizable  from v$sql  where sql_id ='6stmvx0gcybbg';
SQL_ID        CHILD_NUMBER I
------------- ------------ -
6stmvx0gcybbg            0 N

--//is_reoptimizable = 'N'.

总结:
--//12cR2做了一些改进,optimizer_adaptive_statistics=false,避免大量的动态取样对性能的影响.另外即使设置optimizer_adaptive_statistics=true.
--//oracle也保存了动态取样的结果.
--//dbms_stats引入新的参数AUTO_STAT_EXTENSIONS,缺省是off.设置on后再分析自动建立扩展统计信息.

[20181225]12CR2 SQL Plan Directives.txt的更多相关文章

  1. SQL plan directives

    SQL plan directives SQL plan directives含有优化器产生优化的执行计划时需要的附加信息和指令. 在sql执行时,如果cardinality估计有错误,数据库就会创建 ...

  2. [20181007]12cR2 Using SQL Patch 2.txt

    [20181007]12cR2 Using SQL Patch 2.txt --//12cR2 已经把sql打补丁集成进入dbms_sqldiag,不是11g的 DBMS_SQLDIAG_INTERN ...

  3. [20181015]12C SQL Translation Framework.txt

    [20181015]12C SQL Translation Framework.txt --//12c提供一个dba改写sql语句的可能性,实际上10g,11g之前也有一个包DBMS_ADVANCED ...

  4. Oracle SQL操作计划基线总结(SQL Plan Baseline)

    一.基础概念 Oracle 11g開始,提供了一种新的固定运行计划的方法,即SQL plan baseline,中文名SQL运行计划基线(简称基线),能够觉得是OUTLINE(大纲)或者SQL PRO ...

  5. oracle11g中SQL优化(SQL TUNING)新特性之SQL Plan Management(SPM)

    1.   简介 Oracle Database11gR1引进了SQL PlanManagement(简称SPM),一套允许DBA捕获和保持任意SQL语句执行计划最优的新工具,这样,限制了刷新优化器统计 ...

  6. 11g新特性-SQL Plan Management

    在11g之前版本,提供了stored outlines(sql概要)特性来保存sql的执行计划. 在11g中,引入了一个新的特性sql计划管理(sql plan management)特性来保存sql ...

  7. 免費查看SQL PLAN的工具 - SQL Sentry Plan Explorer

    今天 Terry大 介紹給小弟這個 SQL Sentry Plan Explorer 工具,可以用來看SQL Plan. 什麼? 用SSMS看不就很清楚了嗎? 這個Tool有把SQL Plan幫我們整 ...

  8. Oracle 固定执行计划-使用SPM(Sql Plan Management)固定执行计划

    固定执行计划-使用SPM(Sql Plan Management)固定执行计划 转载自:http://www.lunar2013.com/2016/01/固定执行计划-使用spm%EF%BC%88sq ...

  9. 11g的新特性:SQL Plan Management(SPM)

    Oracle11g中,Oracle提供dbms_spm包来管理SQL Plan,SPM是一个预防机制,它记录并评估sql的执行计划,将已知的高效的sql执行计划建立为SQL Plan Baseline ...

随机推荐

  1. IFS简单说明

    bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html bash下的很多命令都会分割单词,绝大多数时候默认是采用空格作 ...

  2. JS_正则表达式_使用字符串创建的正则表达式_反斜杠也需要添加转义符

    备注:   使用字符串创建的正则表达式:"\"也需要加转义符: var reg1=new RegExp("\\w+");       这和 直接使用:var r ...

  3. WebApi HTTP Put 405 Method not allowed

    总结列表: 1. There is already an open DataReader associated with this Connection which must be closed fi ...

  4. 事务隔离级别之Read Uncommitted/WITH(NOLOCK)

    知识点链接 事务隔离级别之Read Uncommitted       https://blog.csdn.net/oyw5201314ck/article/details/79621347 WITH ...

  5. sudo: cd: command not found

    事件起因 今天在aws ubutun上忽然发现的一个问题,执行sudo cd 时出现 sudo: cd: command not found 原因 shell shell是一个命令解析器 所谓shel ...

  6. springMVC_04controller四种配置总结

    一.通过url对应bean,加粗部分为必须有的 <bean class=" org.springframework.web.servlet.handler.BeanNameUrlHan ...

  7. 【Tomcat】Tomcat工作原理

    Tomcat 总体结构 Tomcat 的结构很复杂,但是 Tomcat 也非常的模块化,找到了 Tomcat 最核心的模块,您就抓住了 Tomcat 的“七寸”.下面是 Tomcat 的总体结构图: ...

  8. C#设计模式之十九策略模式(Stragety Pattern)【行为型】

    一.引言 今天我们开始讲“行为型”设计模式的第七个模式,该模式是[策略模式],英文名称是:Stragety Pattern.在现实生活中,策略模式的例子也非常常见,例如,在一个公司中,会有各种工作人员 ...

  9. vbscript 语言通过序列和ADODB实现取号不重复

    目的:通过VBScript脚本利用序列的性质,实现取号不重复 首先,表空间中创建表名为TABLE_YEWID的表格,主要有以下几个字段 -- Create table create table TAB ...

  10. mysql用户授权、数据库权限管理、sql语法详解

    mysql用户授权.数据库权限管理.sql语法详解 —— NiceCui 某个数据库所有的权限 ALL 后面+ PRIVILEGES SQL 某个数据库 特定的权限SQL mysql 授权语法 SQL ...