1 SQL Version 说明
Troubleshooting: High Version Count Issues (Doc ID 296377.1)
High Version Counts For SQL Statements (>1024) Post Upgrade To 12.2 and Above Causing Database Slow Performance (Doc ID 2431353.1)
可以从 AWR 报告查看SQL Version,也可以通过如下 SQL 查看:
select count() as version_count, sql_id from v$sql where is_obsolete = ‘N’group by sql_id having count() > 100;
过高的 SQL Version 也就意味着当子游标过多,如果 SQL 又执行的很频繁,可能会导致 CPU 使用率过高,mutex 争用,从而影响数据库的性能。
在 Oracle 11.2.0.3 的版本中引入了一个隐含参数来控制 SQL Version:_cursor_obsolete_threshold
,当SQL版本超过这个参数设定后,直接舍弃这个游标,重新解析,重头开始。
在 11.2.0.3 版本之前,只能通过补丁和参数(”_cursor_features_enabled” 和 event 106001)可以达成类似的效果。
该隐含参数在不通的版本里默认值也不同:
11.2.0.3: _cursor_obsolete_threshold=100
11.2.0.4: _cursor_obsolete_threshold=1024
12.1: _cursor_obsolete_threshold=1024
12.2 onwards: _cursor_obsolete_threshold=8192
可以看到在 12.2 以后默认值已经改到 8192 了。如果出现了这性能问题,可以考虑修改该参数的值。
2 修改 SQL Version 参数
SQL> col PARAMNAME for a50
SQL> col SESSIONVALUE for a15
SQL> col INSTANCEVALUE for a15
SQL> set lines 190
SQL> select paramName,SessionValue,InstanceValue from hparams where paramname='_cursor_obsolete_threshold';
PARAMNAME SESSIONVALUE INSTANCEVALUE
-------------------------------------------------- --------------- ---------------
_cursor_obsolete_threshold 8192 8192
SQL>
这个参数是静态参数,需要通过 spfile 修改,重启生效:
SQL> alter system set “_cursor_obsolete_threshold”=1024 scope=spfile;
版权声明:本文为博主原创文章,未经博主允许不得转载。