原博客地址:http://blog.csdn.net/tianlesoftware/article/details/6551723
一. 官网的说明
http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/initparams042.htm#REFRN10025
Property |
Description |
Parameter type |
String |
Syntax |
CURSOR_SHARING = { SIMILAR | EXACT | FORCE } |
Default value |
EXACT |
Modifiable |
ALTER SESSION, ALTER SYSTEM |
Basic |
No |
CURSOR_SHARING determines what kind of SQL statements can share the same cursors.
Values:
Allows the creation of a new cursor if sharing an existing cursor, or if the cursor plan is not optimal.
(2)SIMILAR
Causes statements that may differ in some literals, but are otherwise identical, to share a cursor, unless the literals affect either the meaning of the statement or the degree to which the plan is optimized.
(3)EXACT
Only allows statements with identical text to share the same cursor.
--只有SQL 语句完全相同的情况下,才会使用相同的cursor,即执行计划。
Notes:
(1)If you set CURSOR_SHARING, then Oracle recommends the FORCE setting unless you are in a DSS environment. FORCE limits the growth of child cursors that can occur when the setting is SIMILAR.
(2)The value of the CURSOR_SHARING parameter has performance implications. Refer to Oracle Database Performance Tuning Guide before setting this parameter.
1.2 When to Set CURSOR_SHARING to a Nondefault Value
The best practice is to write sharable SQL and use the default of EXACT for CURSOR_SHARING. However, for applications with many similar statements, setting CURSOR_SHARING can significantly improve cursor sharing, resulting in reduced memory usage, faster parses, and reduced latch contention. Consider this approach when statements in the shared pool differ only in the values of literals, and when response time is poor because of a very high number of library cache misses.
Setting CURSOR_SHARING to FORCE or SIMILAR has the following drawbacks:
(1)The database must perform extra work during the soft parse to find a similar statement in the shared pool.
(2)There is an increase in the maximum lengths (as returned by DESCRIBE) of any selected expressions that contain literals in a SELECT statement. However, the actual length of the data returned does not change.
(3)Star transformation is not supported.
(4)If stored outlines were generated with CURSOR_SHARING set to EXACT, then the database does not use stored outlines generated with literals. To avoid this problem, generate outlines with CURSOR_SHARING set to FORCE or SIMILAR and use the CREATE_STORED_OUTLINES parameter.
When deciding whether to set CURSOR_SHARING to FORCE or SIMILAR, consider the performance implications of each setting.
When CURSOR_SHARING is set to FORCE, the database uses one parent cursor and one child cursor for each distinct SQL statement. The database uses the same plan for each execution of the same statement.
When set to SIMILAR, database behavior depends on the presence of histograms:
(1)Histogram absent for column with system-generated bind value
Only one parent cursor and one child cursor exists for each distinct SQL statement. In this case, all executions of a SQL statement use the same plan.
(2)Histogram present for column with system-generated bind value
If the same SQL statement is executed multiple times, each execution has its own child cursor. In this case, the database peeks at bind variable values and create a new child cursor for each distinct value. Thus, each statement execution uses a plan based on the specific literals in the statement.
For example, consider the following statement:
SELECT * FROM hr.employees WHERE employee_id = 101
If FORCE is used, or if SIMILAR is used when no histogram exists, then the database optimizes this statement as if it contained a bind variable and uses bind peeking to estimate cardinality. Statements that differ only in the bind variable share the same execution plan.
If SIMILAR is used, and if a histogram does exist, then the database does not treat the statement as if a bind variable were used. The same query for a different employee may not use the same plan.
If you set CURSOR_SHARING, then Oracle recommends the FORCE setting unless you are in a DSS environment. FORCE limits the growth of child cursors that can occur when the setting is SIMILAR.
Also, function-based indexes may not work when using SIMILAR because the database converts index parameters to bind variables.
For example, if the index is SUBSTR(id,1,3), then the database converts it to SUBSTR("ID",:SYS_B_0,:SYS_B_1)=:id, rendering the index invalid.
Oracle 绑定变量 详解
http://blog.csdn.net/tianlesoftware/archive/2010/09/01/5856430.aspx
二. 测试
2.1 cursor_sharing=exact,这是cursor_sharing的默认值
2.1.1 查看cursor_sharing 值
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
------------------------- -------------------- ---------------------
cursor_sharing string EXACT
2.1.2 查看当前硬解析值
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882056
parse time elapsed 2648194
parse count (total) 12780229
parse count (hard) 9890010(硬解析次数)
parse count (failures) 71
2.1.3 执行一条select 语句,然后查看硬解析次数
SYS@anqing2(rac2)> select * from ta where id=168;
ID NAME
---------- ------------------------------
168 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882061
parse time elapsed 2648196
parse count (total) 12780360
parse count (hard) 9890021
parse count (failures) 71
-- 这里硬解析的次数加一,因为之前SQL 没有解析过,所以需要进行硬解析之后才能执行。
2.1.4 执行与之前类似的SQL,谓词值不一样
SYS@anqing2(rac2)> select * from ta where id=198;
ID NAME
---------- ------------------------------
198 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882061
parse time elapsed 2648196
parse count (total) 12780482
parse count (hard) 9890022
parse count (failures) 71
-- 硬解析次数又加1了,没有重用之前的执行计划
2.1.5 执行相同的SQL 语句
SYS@anqing2(rac2)> select * from ta where id=198;
ID NAME
---------- ------------------------------
198 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882061
parse time elapsed 2648196
parse count (total) 12780543
parse count (hard) 9890022
parse count (failures) 71
-- 测试硬解析没有变化。 重用之前的cursor。
总结:
在这种模式下,只有SQL 语句完全相同的情况下,才会使用相同的cursor,即执行计划。
这种模式下,表有统计信息和没有统计信息的执行计划是有出入的。 所以该模式下的表,需要定期的去收集统计信息。
2.2 cursor_sharing=force
--修改cursor_sharing 值
SYS@anqing2(rac2)> alter session set cursor_sharing='force';
Session altered.
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
------------------------- --------------------- ---------------
cursor_sharing string force
--查看硬解析次数
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882075
parse time elapsed 2648219
parse count (total) 12782090
parse count (hard) 9890067 (硬解析次数)
parse count (failures) 71
-- select 查询
SYS@anqing2(rac2)> select * from ta where id=88;
ID NAME
---------- ------------------------------
88 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882075
parse time elapsed 2648219
parse count (total) 12782215
parse count (hard) 9890068 -- 硬解析次数加一
parse count (failures) 71
-- 执行相同的select,但谓词值不一样
SYS@anqing2(rac2)> select * from ta where id=99;
ID NAME
---------- ------------------------------
99 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882075
parse time elapsed 2648219
parse count (total) 12782285
parse count (hard) 9890068
parse count (failures) 71
--注意,这里的硬解析次数没有变化,这个就是force 的作用。只要sql语句相同,不管谓词值是否相同,都会当成相同的sql,重用之前的cursor,不会进行硬解析。
-- 查看child cursor 信息
SYS@anqing2(rac2)> select sql_text,child_number from v$sql where sql_text like 'select * from ta where%';
SQL_TEXT CHILD_NUMBER
---------------------------------------- ------------
select * from ta where id=:"SYS_B_0" 0
select * from ta where id=:"SYS_B_0" 1
select * from ta where id=:"SYS_B_0" 2
注意:
对于相同的SQL,oracle 在这里将不同的谓词值改成了变量,这样SQL_TEXT 就相同,正常情况下,应该使用同一个cursor,即执行计划,但是在我上面的查询中,Oracle 并没有重用,而是重新生成了一个child_cursor. 这就说明Oracle 认为这个cursor 并不是最优的,所有重新生成了一个。
可以通过如下SQL 查看为什么没有重用之前的cursor:
SQL>select * from v$sql_shared_cursor where sql_id='c9swtz4spq3xz';
如果这里有Y,就是导致不能重用的原因。
Oracle 性能相关的几个 视图 和 参数
http://blog.csdn.net/tianlesoftware/archive/2010/09/06/5867276.aspx
总结:
Allows the creation of a new cursor if sharing an existing cursor, or if the cursor plan is not optimal.
When CURSOR_SHARING is set to FORCE, the database uses one parent cursor and one child cursor for each distinct SQL statement. The database uses the same plan for each execution of the same statement.
FORCE limits the growth of child cursors that can occur when the setting is SIMILAR.
当cursor_sharing 设置为force时, Oracle 会把相同SQL的不同谓词值转换成变量,这样SQL_TEXT就看上去一样。 Oracle 就会使用一个相同的cursor。 这样他们的执行计划也是一样的。
当Oracle 认为存在的cursor 不是最优的时候,就会重新创建一个child cursor,而不重用之前的已经存在cursor。 可以通过v$sql_shared_cursor 查看为什么没有重用。
这样就会和我们上面查询的一样,会有多个child cursor,但是他们的parent cursor是一样的。 这个child cursor 不是无限增常的,force 和similar 都会限制child cursor 的增长。
2.3 cursor_sharing=similar
在这种模式下,对表做统计和没做统计分析是不一样的。有关统计信息,参考我的Blog:
http://blog.csdn.net/tianlesoftware/archive/2009/10/14/4668723.aspx
2.3.1 没有统计信息,没有直方图的情况
-- 查询ta的统计信息
SYS@anqing2(rac2)> exec dbms_stats.delete_table_stats('SYS','TA');
PL/SQL procedure successfully completed.
-- 修改cursor_sharing 模式
SYS@anqing2(rac2)> alter session set cursor_sharing='similar';
Session altered.
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
---------------------- ------------------ ----------------
cursor_sharing string similar
在similer模式下,且没有直方图,等于force 模式。 看测试:
-- 查看硬解析次数
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882222
parse time elapsed 2648406
parse count (total) 12793472
parse count (hard) 9890538
parse count (failures) 74
--做一次select 查询
SYS@anqing2(rac2)> select * from ta where id=238;
ID NAME
---------- ------------------------------
238 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882222
parse time elapsed 2648406
parse count (total) 12793476
parse count (hard) 9890539 硬解析加一
parse count (failures) 74
-- 在次select
SYS@anqing2(rac2)> select * from ta where id=2397;
ID NAME
---------- ----------
2397 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse time cpu 1882337
parse time elapsed 2648558
parse count (total) 12823605
parse count (hard) 9890751
parse count (failures) 75
-- 这里还是有增加硬解析,有点奇怪
-- 查看对应的SQL
SYS@anqing2(rac2)> select sql_text,child_number from v$sql where sql_text like 'select * from ta where%';
SQL_TEXT CHILD_NUMBER
---------------------------------------- ------------
select * from ta where id=238 0
select * from ta where id=2396 0
select * from ta where id=2391 0
select * from ta where id=2397 0
这里并没有将谓词值转换成变量,也就是说similar 没有生效,没有达到force的效果。
在如下Blog 上有对Force 没有生效的一个讨论:
http://forums.oracle.com/forums/message.jspa?messageID=3569923#3569923
摘取一段如下:
Interesting. You may need to flush the shared pool "harder"... Try your testcase again, but issue the ALTER SYSTEM FLUSH SHARED_POOL twice in a row before changing the cursor_sharing setting. It looks like that the statement doesn't show up in V$SQLAREA any longer but still seems not to be flushed entirely and I can find some left-overs of it in the underlying X$KGL library cache fixed tables with the same hash value. After the second "flush shared pool" these are gone and then the cursor sharing works as expected.
解决方法就是在指定cursor_sharing 之前,执行2次flush shared_pool. 测试一下看看。
SYS@anqing2(rac2)> alter system flush shared_pool;
System altered.
SYS@anqing2(rac2)> alter system flush shared_pool;
System altered.
SYS@anqing2(rac2)> alter session set cursor_sharing=similar;
Session altered.
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse count (hard) 9890936
SYS@anqing2(rac2)> select * from ta where id=232;
ID NAME
---------- ----------
232 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse count (hard) 9890946
--从硬解析来看,数量有增加
-- 在查询一次
SYS@anqing2(rac2)> select * from ta where id=23218;
ID NAME
---------- ----------
23218 dave
SYS@anqing2(rac2)> select name,value from v$sysstat where name like '%parse%';
NAME VALUE
------------------------------ ----------
parse count (hard) 9890954
--硬解析又增加了,如果说只有这一条SQL执行,不会增加硬解析。 这个是其他的SQL 带来的硬解析,我们可以查看v$sql验证:
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select * from ta where%';
SQL_TEXT CHILD_NUMBER EXECUTIONS
---------------------------------------- ------------ ----------
select * from ta where id=:"SYS_B_0" 0 2
-- 在这里,已经使转成成了变量,并且执行了2次。 这说明,我们的force是生效的。
2.3.2 有统计信息和直方图
当cursor_sharing 设置为similar,并且表上存在histograms时, 这时候的similar 等于 默认值 exact. 下面我们验证一下。
-- 分析表
SYS@anqing2(rac2)> exec dbms_stats.gather_table_stats('SYS','TA', METHOD_OPT =>'FOR COLUMNS SIZE 10 ID');
PL/SQL procedure successfully completed.
--这里我手工的指定了收集的类型。
-- 查看直方图: histograms
这部分内容,具体可以参考我的blog: Oracle Statistic 统计信息 小结
http://blog.csdn.net/tianlesoftware/archive/2009/10/14/4668723.aspx
SYS@anqing2(rac2)> SELECT column_name, num_distinct, num_buckets, histogram
2 FROM DBA_TAB_COL_STATISTICS WHERE table_name = 'TA' AND column_name = 'ID';
COLUMN_NAME NUM_DISTINCT NUM_BUCKETS HISTOGRAM
------------------------------ ------------ ----------- ---------------
ID 1005510 10 HEIGHT BALANCED
-- 先flush shared_pool 两次
SYS@anqing2(rac2)> alter system flush shared_pool;
System altered.
SYS@anqing2(rac2)> alter system flush shared_pool;
System altered.
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
------------------------ -------------------------------- ----------
cursor_sharing string SIMILAR
-- select 查询和对应的解析
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select count(*) from ta %';
SQL_TEXT CHILD_NUMBER EXECUTIONS
--------------------------------------------- ------------ ----------
select count(*) from ta where id>:"SYS_B_0" 0 3
SYS@anqing2(rac2)> select count(*) from ta where id>10000;
COUNT(*)
----------
990000
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select count(*) from ta %';
SQL_TEXT CHILD_NUMBER EXECUTIONS
--------------------------------------------- ------------ ----------
select count(*) from ta where id>:"SYS_B_0" 0 3
select count(*) from ta where id>:"SYS_B_0" 1 1
--因为ID值和之前的不一样,所以没有重用之前的cursor,而是重新创建了一个
SYS@anqing2(rac2)> select count(*) from ta where id>100;
COUNT(*)
----------
999900
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select count(*) from ta %';
SQL_TEXT CHILD_NUMBER EXECUTIONS
--------------------------------------------- ------------ ----------
select count(*) from ta where id>:"SYS_B_0" 0 3
select count(*) from ta where id>:"SYS_B_0" 1 1
select count(*) from ta where id>:"SYS_B_0" 2 1
-- 这次ID 值又不一样,又重新生成了一个cursor
..... 中间又生成了N 次...
SYS@anqing2(rac2)> select count(*) from ta where id>90808;
COUNT(*)
----------
909192
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select count(*) from ta %';
SQL_TEXT CHILD_NUMBER EXECUTIONS
--------------------------------------------- ------------ ----------
select count(*) from ta where id>:"SYS_B_0" 0 3
select count(*) from ta where id>:"SYS_B_0" 1 1
select count(*) from ta where id>:"SYS_B_0" 2 1
select count(*) from ta where id>:"SYS_B_0" 3 1
select count(*) from ta where id>:"SYS_B_0" 4 1
select count(*) from ta where id>:"SYS_B_0" 5 1
select count(*) from ta where id>:"SYS_B_0" 6 1
select count(*) from ta where id>:"SYS_B_0" 7 1
-- 这个就像我们开始说的,虽然会对变量进行转换,但不会重用,只有谓词值一样的时候才重用之前的cursor。
SYS@anqing2(rac2)> select count(*) from ta where id>90808;
COUNT(*)
----------
909192
SYS@anqing2(rac2)> select sql_text,child_number,executions from v$sql where sql_text like 'select count(*) from ta %';
SQL_TEXT CHILD_NUMBER EXECUTIONS
--------------------------------------------- ------------ ----------
select count(*) from ta where id>:"SYS_B_0" 0 3
select count(*) from ta where id>:"SYS_B_0" 1 1
select count(*) from ta where id>:"SYS_B_0" 2 1
select count(*) from ta where id>:"SYS_B_0" 3 1
select count(*) from ta where id>:"SYS_B_0" 4 1
select count(*) from ta where id>:"SYS_B_0" 5 1
select count(*) from ta where id>:"SYS_B_0" 6 1
select count(*) from ta where id>:"SYS_B_0" 7 2
-- 注意这里,因为我们执行了一个一样的SQL,包括谓词,这里的重用了之前的cursor。
总结:
当cursor_sharing 设置为similar时,Oracle 会对SQL 的位置值转换成常量,这个和force 一样。 但是不同的是:
(1)当字段上有histograms时, 这时等于exact,虽然SQL text 一样,但谓词值不同就不会重用cursor。 只有SQL 语句完全一样,包括谓词值,才会重用cursor。
(2)当没有statstics时,即没有histograms,这时等于force,只要SQL 语句一样,就会重用cursor。
三. similar 模式对expdp 带来的影响
在eygle 的blog上看到similar 对增加expdp备份的时间。
原理链接如下:
http://www.eygle.com/archives/2011/01/cursor_sharing_expdp.html
相关链接:
Oracle 10g Data Pump Expdp/Impdp 详解
http://blog.csdn.net/tianlesoftware/archive/2009/10/15/4674224.aspx
Oracle expdp/impdp 使用示例
http://blog.csdn.net/tianlesoftware/archive/2011/03/18/6260138.aspx
3.1按照默认的expdp
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cursor_sharing string EXACT
[oracle@rac2 backup]$ expdp /'/ as sysdba/' directory=backup full=y dumpfile=fullexp.dmp logfile=fullexp.log
Export: Release 10.2.0.4.0 - Production on Friday, 17 June, 2011 13:54:40
...............
Job "SYS"."SYS_EXPORT_FULL_01" successfully completed at 14:05:49
测试库,全备花了11分钟。
3.2 用similar 模式 expdp 备份
cursor_sharing是一个动态参数,可以在执行expdp之前进行修改,然后执行导出, 备份完在改回来。
SYS@anqing2(rac2)> alter system set cursor_sharing=similar scope=memory;
System altered.
SYS@anqing2(rac2)> show parameter cursor_sharing
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cursor_sharing string SIMILAR
[oracle@rac2 backup]$ expdp /'/ as sysdba/' directory=backup full=y dumpfile=fullexp.dmp logfile=fullexp.log
Export: Release 10.2.0.4.0 - Production on Friday, 17 June,2011 13:40:37
....
Job "SYS"."SYS_EXPORT_FULL_01" successfully completed at 13:52:42
备份了12分钟.
因为库不大,所以差距不明显. 不过如果库大的话,一般也不会用expdp来备份。所以这里作为一个知识点,了解一下。
相关推荐
Oracle的CURSOR_SHARING参数是数据库性能优化中的一个重要设置,它决定了SQL语句在什么情况下可以共享相同的游标(cursor)。游标在Oracle数据库中扮演着关键角色,它们是执行查询时保存信息的结构,包括关于如何从...
从 Oracle 8i 开始,新引入了 CURSOR_SHARING 参数,该参数的主要目的就是为了解决在编程过程中已大量使用的硬编码 SQL 问题。 Oracle 执行计划是 Oracle 数据库性能调整的关键部分,了解这些背景知识和重要概念...
Oracle初始化参数是数据库管理系统Oracle中用来配置数据库运行特性的关键元素。这些参数定义了数据库的行为,包括内存管理、性能优化、安全策略、备份与恢复、并发处理等方面。下面是对一些重要参数的详细解释: 1....
《Oracle SQL 规则与优化详解》 设计一个优秀的系统,首要之义在于在规划之初就考虑到性能优化,并持续进行测试。"Tuning before you start designing"这一原则强调了优化的重要性,它要求我们在构建系统时就要有...
由于此Bug与cursor_sharing参数设置有关,建议用户不要将cursor_sharing设置为FORCE或SIMILAR。如果需要保持cursor_sharing设置,可以通过保持较低的游标版本计数或设置较高游标过时阈值来避免游标成为过时状态。...
### ORACLE 初始化参数详解 #### 一、概述 在Oracle 8i系统中,初始化参数是配置数据库行为的重要工具。这些参数控制了数据库的各种运行特性,包括但不限于性能优化、安全性设置、故障诊断等方面。本文将详细解读...
通过合理调整共享池参数、使用捆绑变量、优化CURSOR_SHARING参数等方式,可以显著提升Oracle数据库的性能表现。此外,操作系统层面的调整也不容忽视,合理的内存配置和高效的磁盘I/O技术对于保障数据库性能至关重要...
### Oracle 11g安装后参数规范设置详解 #### 一、引言 在完成Oracle 11g的安装及数据库构建之后,为了确保数据库能够高效稳定地运行,需要进行一系列参数配置与优化。这些参数调整不仅涉及RAC(Real Application ...
- 设置其他参数:例如`shared_pool_size`、`cursor_sharing`、`cursor_space_for_time`、`open_cursors`、`session_cached_cursors`和`pre_page_sga`等参数,这些参数的调整有助于优化Oracle性能。 - **重启...
如果命中率太低,需要考虑加大共享池、绑定变量、修改 cursor_sharing 等参数来优化性能。 二、共享池内存使用率 共享池内存使用率是指 Oracle 共享池中剩余内存的百分比。计算公式为: SQL> SELECT (1 - ROUND...
2. **减少硬解析**:通过优化SQL语句、合理设置`cursor_sharing`参数以及调整`shared_pool_size`等措施减少硬解析次数。 3. **提高SQL重用率**:利用SQL绑定变量等技术提高SQL语句的重用率,减少不必要的解析操作。 ...
### Oracle DataGuard 环境搭建详解:使用Duplicate方法 #### 一、Oracle DataGuard简介与应用场景 Oracle DataGuard是一种高可用性和灾难恢复解决方案,它能够保护数据免受逻辑和物理故障的影响。DataGuard通过...
### Oracle SGA调优知识点详解 #### 一、SGA简介 SGA(System Global Area)是Oracle数据库的一个重要组成部分,它是一个共享内存区域,由多个数据库进程共享,用于存储数据库信息并加速对这些信息的访问。SGA主要...
- **参数调整:** 可以通过调整 Oracle 的参数来优化 SQL 的执行计划,如设置合适的 `cursor_sharing` 参数值等。 4. **使用绑定变量:** - **绑定变量的使用:** 当应用程序需要频繁执行相同的 SQL 但每次传入的...
较高的Cursors/Session比率可能意味着解析的SQL语句过多,可能需要优化SQL语句或调整 cursor_sharing 参数。 4. **CPU Utilization**:通过对比Elapsed Time和DB Time,可以推算出CPU利用率。例如,在一个有8个逻辑...
- 调整 `CURSOR_SHARING` 参数以改善 SQL 语句共享。 #### 六、调整缓冲区高速缓存 (Buffer Cache) 的性能 缓冲区高速缓存主要用于存储数据块,提高数据访问速度。合理配置缓冲区高速缓存可以显著降低磁盘 I/O ...
- **减少硬解析**:如果硬解析次数过高,可以通过调整`cursor_sharing`参数来改善SQL语句的重用率。 - **优化绑定变量使用**:合理使用绑定变量可以显著减少硬解析的发生。 - **调整缓存设置**:通过调整如`shared_...
- `SESSION_PERSISTENT_CURSOR_SHARING`:控制游标复用策略,以减少内存占用。 - `DB_CONNECTION_LOAD_BALANCE`:用于控制客户端负载均衡,防止某些服务器进程过度负载。 总之,Oracle 11g的DRCP连接方式提供了更...
可以尝试启用`cursor_sharing=similar`或`cursor_sharing=force`参数来改善这一情况,但需要注意的是,这些设置可能会引入新的问题。 9. **Sorts**:每秒或每事务的排序次数。较高的排序次数可能表明查询优化不足或...