ArcSDE性能优化-对于SDE 库更改 Oracle 序列的高速缓存大小



看的很好,存下来~

ArcSDE性能优化-对于SDE 库更改 Oracle 序列的高速缓存大小

ArcSDE用户中

• state_id_generator_nc 
• connection_id_generator 
• version_id_generator
三个序列经常使用,但是默认的Cache SIZE等于0

Oracle 序列是一个数据库对象,提供唯一的整数值。序列高速缓存的大小决定多少 Oracle 预前分配在内存中,在共享池中的值。通过预分配值,Oracle 将返回下一个唯一值从内存提供更快地访问信息。

设置高速缓存大小 0 可能导致丢失的序列值,如果系统关机突然再大一点。当系统出现故障时,保留在内存中的值都将丢失的序列。

例如,假设已创建一个序列的高速缓存大小为 100。第一次使用序列,则 Oracle 缓存值 1- 100 的内存。随后,Oracle 会话使用高速缓存的信息,并使用值 1- 45。此时 Oracle 关闭突然。当序列用于启动、 Oracle 缓存值 101-200 的内存,从而在值中丢失了 46 -100 之后。


此外,已缓存共享池中的序列值在数据库的操作时可以造成老化。可以使用DMBS_SHARED_POOL 存储过程,避免老化序列。


更改序列的Cache SIZE值步骤

1:

  1. ALTER SEQUENCE sde.connection_id_generator CACHE 1000  
  2.   
  3.   
  4.   
  5. ALTER SEQUENCE sde.state_id_generator_nc CACHE 1000  
  6.   
  7.   
  8.   
  9. ALTER SEQUENCE sde.version_id_generator CACHE 1000  
ALTER SEQUENCE sde.connection_id_generator CACHE 1000



ALTER SEQUENCE sde.state_id_generator_nc CACHE 1000



ALTER SEQUENCE sde.version_id_generator CACHE 1000

2:

  1. exec sys.DBMS_SHARED_POOL.KEEP('sde.connection_id_generator''Q')  
  2.   
  3.   
  4.   
  5. exec sys.DBMS_SHARED_POOL.KEEP('sde.state_id_generator_nc''Q')  
  6.   
  7.   
  8.   
  9. exec sys.DBMS_SHARED_POOL.KEEP('sde.version_id_generator''Q')  
exec sys.DBMS_SHARED_POOL.KEEP('sde.connection_id_generator', 'Q')



exec sys.DBMS_SHARED_POOL.KEEP('sde.state_id_generator_nc', 'Q')



exec sys.DBMS_SHARED_POOL.KEEP('sde.version_id_generator', 'Q')
  1. 介绍一下:<pre class="sql" name="code">exec sys.DBMS_SHARED_POOL.KEEP</pre>  
  2. <pre></pre>  
  3. <pre class="sql" name="code"--  Keep an object in the shared pool.  Once an object has been keeped in  
  4.   --    the shared pool, it is not subject to aging out of the pool.  This  
  5.   --    may be useful for certain semi-frequently used large objects since  
  6.   --    when large objects are brought into the shared pool, a larger  
  7.   --    number of other objects (much more than the size of the object  
  8.   --    being brought in, may need to be aged out in order to create a  
  9.   --    contiguous area large enough.  
  10.   --    WARNING:  This procedure may not be supported in the future when  
  11.   --    and if automatic mechanisms are implemented to make this  
  12.   --    unnecessary.  
  13.   --  Input arguments:  
  14.   --    name  
  15.   --      The name of the object to keep.  There are two kinds of objects:  
  16.   --      PL/SQL objects, triggers, sequences, types and Java objects,  
  17.   --      which are specified by name, and  
  18.   --      SQL cursor objects which are specified by a two-part number  
  19.   --      (indicating a location in the shared pool).  For example:  
  20.   --        dbms_shared_pool.keep('scott.hispackage')  
  21.   --      will keep package HISPACKAGE, owned by SCOTT.  The names for  
  22.   --      PL/SQL objects follows SQL rules for naming objects (i.e.,  
  23.   --      delimited identifiers, multi-byte names, etc. are allowed).  
  24.   --      A cursor can be keeped by  
  25.   --        dbms_shared_pool.keep('0034CDFF, 20348871', 'C')  
  26.   --      The complete hexadecimal address must be in the first 8 characters.  
  27.   --      The value for this identifier is the concatenation of the  
  28.   --      'address' and 'hash_value' columns from the v$sqlarea view.  This  
  29.   --      is displayed by the 'sizes' call above.  
  30.   --      Currently 'TABLE' and 'VIEW' objects may not be keeped.  
  31.   --    flag  
  32.   --      This is an optional parameter.  If the parameter is not specified,  
  33.   --        the package assumes that the first parameter is the name of a  
  34.   --        package/procedure/function and will resolve the name.  Otherwise,  
  35.   --        the parameter is a character string indicating what kind of object  
  36.   --        to keep the name identifies.  The string is case insensitive.  
  37.   --        The possible values and the kinds of objects they indicate are  
  38.   --        given in the following table:  
  39.   --        Value        Kind of Object to keep  
  40.   --        -----        ----------------------  
  41.   --<span style="white-space: pre;">   </span>      P          package/procedure/function  
  42.   --<span style="white-space: pre;">   </span>      Q          sequence  
  43.   --<span style="white-space: pre;">   </span>      R          trigger  
  44.   --<span style="white-space: pre;">   </span>      T          type  
  45.   --          JS         java source  
  46.   --          JC         java class  
  47.   --<span style="white-space: pre;">   </span>      JR         java resource  
  48.   --<span style="white-space: pre;">   </span>      JD         java shared data  
  49.   --<span style="white-space: pre;">   </span>      C          cursor  
  50.   --      If and only if the first argument is a cursor address and hash-value,  
  51.   --        the flag parameter should be set to 'C' (or 'c').  
  52.   --  Exceptions:  
  53.   --    An exception will raised if the named object cannot be found.  
  54. </pre>  
  55. <p>附带:执行CACHE的性能对比,非ArcSDE例子</p>  
  56. <p></p>  
  57. <p><span style='font-family: "Microsoft YaHei"; font-size: 18px;'><br>  
  58. </span></p>  
  59. <p><span style='font-family: "Microsoft YaHei"; font-size: 18px;'></span></p>  
  60. <pre class="sql" name="code">一个网友RAC 系统上的测试时结果:  
  61. nocache:               2100s  
  62. cache =1000:          55s  
  63. 差别很明显。  
  64.    
  65.    
  66. 测试一:  
  67. SQL> create sequence seq_1 nocache;  
  68. 序列已创建。  
  69. SQL> set timing on;  
  70. SQL> declare  
  71.   2  x number;  
  72.   3  begin  
  73.   4  for i in 1 .. 10000 loop  
  74.   5  select seq_1.nextval into x from dual;  
  75.   6  end loop;  
  76.   7  end;  
  77.   8  /  
  78. PL/SQL 过程已成功完成。  
  79.    
  80. 已用时间:  00: 00: 02.26  
  81.    
  82. 测试二:  
  83. SQL> create sequence seq_2 cache 20;  
  84. 序列已创建。  
  85. 已用时间:  00: 00: 00.01  
  86. SQL> declare  
  87.   2  x number;  
  88.   3  begin  
  89.   4  for i in 1 .. 10000 loop  
  90.   5  select seq_2.nextval into x from dual;  
  91.   6  end loop;  
  92.   7  end;  
  93.   8  /  
  94. PL/SQL 过程已成功完成。  
  95.    
  96. 已用时间:  00: 00: 00.46  
  97.    
  98. 测试三:  
  99. SQL> create sequence seq_3 cache 100;  
  100.    
  101. 序列已创建。  
  102.    
  103. 已用时间:  00: 00: 00.05  
  104. SQL> declare  
  105.   2  x number;  
  106.   3  begin  
  107.   4  for i in 1 .. 10000 loop  
  108.   5  select seq_3.nextval into x from dual;  
  109.   6  end loop;  
  110.   7  end;  
  111.   8  /  
  112.    
  113. PL/SQL 过程已成功完成。  
  114.    
  115. 已用时间:  00: 00: 00.37  
  116.    
  117.    
  118. 测试四:  
  119. SQL> create sequence seq_4 cache 1000;  
  120. 序列已创建。  
  121. 已用时间:  00: 00: 00.04  
  122. SQL> declare  
  123.   2  x number;  
  124.   3  begin  
  125.   4  for i in 1 .. 40000 loop  
  126.   5  select seq_4.nextval into x from dual;  
  127.   6  end loop;  
  128.   7  end;  
  129.   8  /  
  130.    
  131. PL/SQL 过程已成功完成。  
  132.    
  133. 已用时间:  00: 00: 01.31  
  134. SQL> declare  
  135.   2  x number;  
  136.   3  begin  
  137.   4  for i in 1 .. 40000 loop  
  138.   5  select seq_1.nextval into x from dual;  
  139.   6  end loop;  
  140.   7  end;  
  141.   8  /  
  142.    
  143. PL/SQL 过程已成功完成。  
  144.    
  145. 已用时间:  00: 00: 09.33  
  146. SQL>  
  147.    
  148.    
  149.    
  150. 小结:  
  151.    
  152. 在自己的本本上测试的,Oracle 11gR2.  单Instance数据库单会话循环不间断取1-4万个值。  
  153. nocache:             2.26s          10000     
  154. cache:20              0.46s          10000  
  155. cache:100             0.37s          10000  
  156. cache:1000            1.31s          40000  
  157. nocache:             9.33s         40000  
  158.    
  159. 基本上cache 大于20的时候性能基本可以接受,nocache的时候性能确实很差.</pre><br>  
  160. <p><br>  
  161. </p>  
  162. <pre></pre>  
  163. <pre></pre>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值