二、在Cursor_sharing参数值不同的时对SQL的影响: 2.1 创建实验环境: ---首先创建一张jack表--- 1 SQL>createtable jack (idint,namevarchar2(10));23Tablecreated.4---产生一些数据--- 5 SQL>insertinto jackvalues(1,'aa');671row created.89 SQL>insertinto jackvalues(2,'bb');10111row created....
oracle cursor_sharing 参数oracle cursor_sharing 在Oracle数据库中,`CURSOR_SHARING`是一个数据库参数,用于控制SQL语句中的字面值替换(Literal Replacement)策略。这个参数的值决定了Oracle是否尝试共享SQL语句中相似的SQL区块(SQL片段),以提高SQL语句的共享度,减少数据库资源的消耗。 `CURSOR_SHARING`参数有以下几个...
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...
Cursor_sharing参数有3个值可以设置: 1)、EXACT:通常来说,exact值是Oracle推荐的,也是默认的,它要求SQL语句在完全相同时才会重用,否则会被重新执行硬解析操作。 2)、SIMILAR:similar是在Oracle认为某条SQL语句的谓词条件可能会影响到它的执行计划时,才会被重新分析,否则将重用SQL。 3)、FORCE:force是在任何情况下,...
1.1 CURSOR_SHARING CURSOR_SHARING determines what kind of SQL statements can share the same cursors. Values: (1)FORCE Allows the creation of a new cursor if sharing an existing cursor, or if the cursor plan is not optimal. (2)SIMILAR ...
cursor_sharing 参数用于控制游标共享的启用与否。当该参数设置为 TRUE 时,表示允许游标共享;设置为 FALSE 时,表示禁止游标共享。游标共享可以减少系统资源消耗,提高查询效率,尤其是在大量数据查询时,效果更为明显。 三、cursor_sharing 参数的取值范围和推荐值 cursor_sharing 参数的取值范围为 BOOLEAN,即 TRUE 和 FAL...
执行上述sql语句之后,使用select NAME,value from v$sysstat where name='parse count (hard)'查询,其硬解析的值依然是10207,这个就是将cursor_sharing的值为force 的作用,只要sql语句相同,不管谓词值是否相同,都会当成相同的sql,重用之前的cursor,不会进行硬解析。
从Oracle9i开始,CURSOR_SHARING的值增加了一个SIMILAR,Oracle推荐使用SIMILAR来代替FORCE,当参数设置为SIMILAR时,Oracle不会强制将全部的变量进行绑定,而是根据一些预定义的设置进行判断。 无论是FORCE参数还是改进后的SIMILAR参数,都是解决绑定变量的替代方式,这些方式都可能带来一些bug以及很多未知的东西。只有有可能就应该...
2.2 cursor_sharing=exact的情况: 复制代码 ---将cursor_sharing设置为exact--- SQL> alter session set cursor_sharing=exact; Session altered. SQL> alter session set sql_trace=true; Session altered. SQL> select * from weisi_t_exact where id=1; ID ...
--只有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. ...