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

32 篇文章 0 订阅
8 篇文章 0 订阅

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  
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')  
  1. 介绍一下:<pre name="code" class="sql">exec sys.DBMS_SHARED_POOL.KEEP  
 
  1.  --  Keep an object in the shared pool.  Once an object has been keeped in  
  2.   --    the shared pool, it is not subject to aging out of the pool.  This  
  3.   --    may be useful for certain semi-frequently used large objects since  
  4.   --    when large objects are brought into the shared pool, a larger  
  5.   --    number of other objects (much more than the size of the object  
  6.   --    being brought in, may need to be aged out in order to create a  
  7.   --    contiguous area large enough.  
  8.   --    WARNING:  This procedure may not be supported in the future when  
  9.   --    and if automatic mechanisms are implemented to make this  
  10.   --    unnecessary.  
  11.   --  Input arguments:  
  12.   --    name  
  13.   --      The name of the object to keep.  There are two kinds of objects:  
  14.   --      PL/SQL objects, triggers, sequences, types and Java objects,  
  15.   --      which are specified by name, and  
  16.   --      SQL cursor objects which are specified by a two-part number  
  17.   --      (indicating a location in the shared pool).  For example:  
  18.   --        dbms_shared_pool.keep('scott.hispackage')  
  19.   --      will keep package HISPACKAGE, owned by SCOTT.  The names for  
  20.   --      PL/SQL objects follows SQL rules for naming objects (i.e.,  
  21.   --      delimited identifiers, multi-byte names, etc. are allowed).  
  22.   --      A cursor can be keeped by  
  23.   --        dbms_shared_pool.keep('0034CDFF, 20348871', 'C')  
  24.   --      The complete hexadecimal address must be in the first 8 characters.  
  25.   --      The value for this identifier is the concatenation of the  
  26.   --      'address' and 'hash_value' columns from the v$sqlarea view.  This  
  27.   --      is displayed by the 'sizes' call above.  
  28.   --      Currently 'TABLE' and 'VIEW' objects may not be keeped.  
  29.   --    flag  
  30.   --      This is an optional parameter.  If the parameter is not specified,  
  31.   --        the package assumes that the first parameter is the name of a  
  32.   --        package/procedure/function and will resolve the name.  Otherwise,  
  33.   --        the parameter is a character string indicating what kind of object  
  34.   --        to keep the name identifies.  The string is case insensitive.  
  35.   --        The possible values and the kinds of objects they indicate are  
  36.   --        given in the following table:  
  37.   --        Value        Kind of Object to keep  
  38.   --        -----        ----------------------  
  39.   --<span style="white-space:pre">   </span>      P          package/procedure/function  
  40.   --<span style="white-space:pre">   </span>      Q          sequence  
  41.   --<span style="white-space:pre">   </span>      R          trigger  
  42.   --<span style="white-space:pre">   </span>      T          type  
  43.   --          JS         java source  
  44.   --          JC         java class  
  45.   --<span style="white-space:pre">   </span>      JR         java resource  
  46.   --<span style="white-space:pre">   </span>      JD         java shared data  
  47.   --<span style="white-space:pre">   </span>      C          cursor  
  48.   --      If and only if the first argument is a cursor address and hash-value,  
  49.   --        the flag parameter should be set to 'C' (or 'c').  
  50.   --  Exceptions:  
  51.   --    An exception will raised if the named object cannot be found.  

附带:执行CACHE的性能对比,非ArcSDE例子


  1. 一个网友RAC 系统上的测试时结果:  
  2. nocache:               2100s  
  3. cache =1000:          55s  
  4. 差别很明显。  
  5.    
  6.    
  7. 测试一:  
  8. SQL> create sequence seq_1 nocache;  
  9. 序列已创建。  
  10. SQL> set timing on;  
  11. SQL> declare  
  12.   2  x number;  
  13.   3  begin  
  14.   4  for i in 1 .. 10000 loop  
  15.   5  select seq_1.nextval into x from dual;  
  16.   6  end loop;  
  17.   7  end;  
  18.   8  /  
  19. PL/SQL 过程已成功完成。  
  20.    
  21. 已用时间:  00: 00: 02.26  
  22.    
  23. 测试二:  
  24. SQL> create sequence seq_2 cache 20;  
  25. 序列已创建。  
  26. 已用时间:  00: 00: 00.01  
  27. SQL> declare  
  28.   2  x number;  
  29.   3  begin  
  30.   4  for i in 1 .. 10000 loop  
  31.   5  select seq_2.nextval into x from dual;  
  32.   6  end loop;  
  33.   7  end;  
  34.   8  /  
  35. PL/SQL 过程已成功完成。  
  36.    
  37. 已用时间:  00: 00: 00.46  
  38.    
  39. 测试三:  
  40. SQL> create sequence seq_3 cache 100;  
  41.    
  42. 序列已创建。  
  43.    
  44. 已用时间:  00: 00: 00.05  
  45. SQL> declare  
  46.   2  x number;  
  47.   3  begin  
  48.   4  for i in 1 .. 10000 loop  
  49.   5  select seq_3.nextval into x from dual;  
  50.   6  end loop;  
  51.   7  end;  
  52.   8  /  
  53.    
  54. PL/SQL 过程已成功完成。  
  55.    
  56. 已用时间:  00: 00: 00.37  
  57.    
  58.    
  59. 测试四:  
  60. SQL> create sequence seq_4 cache 1000;  
  61. 序列已创建。  
  62. 已用时间:  00: 00: 00.04  
  63. SQL> declare  
  64.   2  x number;  
  65.   3  begin  
  66.   4  for i in 1 .. 40000 loop  
  67.   5  select seq_4.nextval into x from dual;  
  68.   6  end loop;  
  69.   7  end;  
  70.   8  /  
  71.    
  72. PL/SQL 过程已成功完成。  
  73.    
  74. 已用时间:  00: 00: 01.31  
  75. SQL> declare  
  76.   2  x number;  
  77.   3  begin  
  78.   4  for i in 1 .. 40000 loop  
  79.   5  select seq_1.nextval into x from dual;  
  80.   6  end loop;  
  81.   7  end;  
  82.   8  /  
  83.    
  84. PL/SQL 过程已成功完成。  
  85.    
  86. 已用时间:  00: 00: 09.33  
  87. SQL>  
  88.    
  89.    
  90.    
  91. 小结:  
  92.    
  93. 在自己的本本上测试的,Oracle 11gR2.  单Instance数据库单会话循环不间断取1-4万个值。  
  94. nocache:             2.26s          10000     
  95. cache:20              0.46s          10000  
  96. cache:100             0.37s          10000  
  97. cache:1000            1.31s          40000  
  98. nocache:             9.33s         40000  
  99.    
  100. 基本上cache 大于20的时候性能基本可以接受,nocache的时候性能确实很差.  
  101. http://blog.csdn.net/linghe301/article/details/6852693
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值