博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[20170625]12c Extended statistics.txt
阅读量:6498 次
发布时间:2019-06-24

本文共 3928 字,大约阅读时间需要 13 分钟。

[20170625]12c Extended statistics.txt

--//别人的系统12c,awr报表出现大量调用执行如下sql语句.
select default$ from col$ where rowid=:1;
--//google看了一下,问题出在Extended statistics的问题,12c 会自动收集扩展统计信息.找到如下链接:
--//https://blog.dbi-services.com/sql-plan-directives-strike-again/
1.环境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.1.0.1.0     Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0
--//特别在应用不使用绑定变量的情况下,12c这个问题会更严重,据说12.2已经解决这个问题.
select default$ from col$ where rowid=:1;
--//sql_id=''47r1y8yn34jmj'.
--//仅仅记录作者的结论:
--//https://blog.dbi-services.com/sql-plan-directives-strike-again/
Conclusion
In that case, the solution is both to change the application to use bind variable (it's perl, very easy) and apply the
patch.
I'm sharing that because it's a good illustration of what side effects can do, as well as a good example of methodical
troubleshooting. When you know the reason without blind guesses, you can address the root cause. If you don't, the risk
is that you add even more side effects.
By the way, please use bind variables…
--//我也google,也许设置"_optimizer_enable_extended_stats"=FALSE,也可以.不过这样估计就不能使用建立与使用这样的统计.
alter system set "_optimizer_enable_extended_stats"=FALSE scope=both;
SYS@test> @ hide _optimizer_enable_extended_stats
NAME                             DESCRIPTION                                        DEFAULT_VALUE SESSION_VALUE SYSTEM_VALUE
-------------------------------- -------------------------------------------------- ------------- ------------- ------------
_optimizer_enable_extended_stats use extended statistics for selectivity estimation TRUE          TRUE          TRUE
--//再或者设置如下,这也是我使用的方法:
alter session set cursor_sharing="force" scope=both;
--//删除不需要的扩展统计,例子:
exec dbms_stats.drop_extended_stats(ownname => 'SCOTT',tabname => 'EMP',extension => '("ENAME","JOB")');
2.自己手工建立删除看看.
SCOTT@test01p> select DBMS_STATS.create_extended_stats(ownname => 'SCOTT',tabname => 'EMP',extension =>'("ENAME","DEPTNO")') c30 from dual ;
C30
------------------------------
SYS_STUU2WA2Z3E__3QS4G4E5M$QPA
--//注不能exec 来执行.
SCOTT@test01p> column EXTENSION_NAME format a30
SCOTT@test01p> select * from dba_stat_extensions where owner='SCOTT' ;
OWNER      TABLE_NAME EXTENSION_NAME                 EXTENSION                CREATOR DRO
---------- ---------- ------------------------------ ------------------------ ------- ---
SCOTT      EMP        SYS_STUU2WA2Z3E__3QS4G4E5M$QPA ("ENAME","DEPTNO")       USER    YES
           EMP        SYS_NC00009$                   (STANDARD_HASH("ENAME")) SYSTEM  NO
SCOTT@test01p> exec dbms_stats.drop_extended_stats(ownname => 'SCOTT',tabname => 'EMP',extension => '("ENAME","DEPTNO")');
PL/SQL procedure successfully completed.
SCOTT@test01p> select * from dba_stat_extensions where owner='SCOTT' ;
OWNER      TABLE_NAME EXTENSION_NAME                 EXTENSION                CREATOR DRO
---------- ---------- ------------------------------ ------------------------ ------- ---
SCOTT      EMP        SYS_NC00009$                   (STANDARD_HASH("ENAME")) SYSTEM  NO
--//可以发现已经删除.
--//补充:https://smarttechways.com/2017/01/06/extended-stats-in-oracle/
SQL plan directives can be used by Oracle to determine if extended statistics specifically column groups, are missing
and would resolve the cardinality misestimates. After a SQL directive is used the optimizer decides if the cardinality
not be estimate could be resolved with a column group. If so, the database can automatically create that column group
the next time statistics are gathered on the appropriate table.
This step is "always on" in Oracle Database 12c Release 1, but from Oracle Database 12c Release 2, it is controlled by
the DBMS_STATS preference AUTO_STAT_EXTENSIONS. Note that the default is OFF, so to enable automatic column group
creation the following.
EXEC DBMS_STATS.SET_GLOBAL_PREFS('AUTO_STAT_EXTENSIONS', 'ON');
--//我的环境没有这个参数.
总结:
1.我个人的建议不要过早的使用XX.1的版本,这样就是人家试验品.
2.国内应用大量不使用绑定变量,这个也是国内使用oracle数据库的通病.

转载于:https://www.cnblogs.com/lfree/p/7078983.html

你可能感兴趣的文章
vmware的三种网络模式讲解
查看>>
Directx11教程(61) tessellation学习(3)
查看>>
Directx11教程(11) 增加一个debug宏
查看>>
着急上火
查看>>
C# 接口
查看>>
MYSQL体系结构-来自期刊
查看>>
PHP——图片上传
查看>>
mysql的基本知识
查看>>
exchange 2003配置ASSP 反垃圾邮件
查看>>
CQRS学习——最小单元的Cqrs(CommandEvent)[其一]
查看>>
webpack入门(二)what is webpack
查看>>
UnitOfWork以及其在ABP中的应用
查看>>
学习C语言必须知道的理论知识(第一章)
查看>>
for语句内嵌例题与个人理解
查看>>
眠眠interview Question
查看>>
Linux C++/Java/Web/OC Socket网络编程
查看>>
[转]CSS hack大全&详解
查看>>
c语言第八次作业
查看>>
RPC-client异步收发核心细节?
查看>>
POJ-1753 Flip Game 枚举 状态压缩
查看>>