Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3672822
  • 博文数量: 715
  • 博客积分: 1860
  • 博客等级: 上尉
  • 技术积分: 7745
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-07 08:51
个人简介

偶尔有空上来看看

文章分类

全部博文(715)

文章存档

2023年(75)

2022年(134)

2021年(238)

2020年(115)

2019年(11)

2018年(9)

2017年(9)

2016年(17)

2015年(7)

2014年(4)

2013年(1)

2012年(11)

2011年(27)

2010年(35)

2009年(11)

2008年(11)

分类: Oracle

2022-03-29 21:05:37

貌似没啥用,先记录下来

  1. set echo off
  2. spool pool_est
  3. /*
  4. *********************************************************
  5. * *
  6. * TITLE : Shared Pool Estimation *
  7. * CATEGORY : Information, Utility *
  8. * SUBJECT AREA : Shared Pool *
  9. * DESCRIPTION : Estimates shared pool utilization *
  10. * based on current database usage. This should be *
  11. * run during peak operation, after all stored *
  12. * objects i.e. packages, views have been loaded. *
  13. * NOTE: Modified to work with later versions 4/11/06 *
  14. * *
  15. ********************************************************/
  16. Rem If running MTS uncomment the mts calculation and output
  17. Rem commands.
  18.  
  19. set serveroutput on;
  20.  
  21. declare
  22.         object_mem number;
  23.         shared_sql number;
  24.         cursor_ovh number;
  25.         cursor_mem number;
  26.         mts_mem number;
  27.         used_pool_size number;
  28.         free_mem number;
  29.         pool_size varchar2(512); -- same as V$PARAMETER.VALUE
  30. begin
  31.  
  32. -- Stored objects (packages, views)
  33. select sum(sharable_mem) into object_mem from v$db_object_cache
  34. where type <> 'CURSOR';
  35.  
  36. -- Shared SQL -- need to have additional memory if dynamic SQL used
  37. select sum(sharable_mem) into shared_sql from v$sqlarea;
  38.  
  39. -- User Cursor Usage -- run this during peak usage.
  40. -- assumes 250 bytes per open cursor, for each concurrent user.
  41. select sum(250*users_opening) into cursor_ovh from v$sqlarea;

  42. select sum(sharable_mem) into cursor_mem from v$db_object_cache
  43. WHERE type='CURSOR';
  44.  
  45. -- For a test system -- get usage for one user, multiply by # users
  46. -- select (250 * value) bytes_per_user
  47. -- from v$sesstat s, v$statname n
  48. -- where s.statistic# = n.statistic#
  49. -- and n.name = 'opened cursors current'
  50. -- and s.sid = 25; -- where 25 is the sid of the process
  51.  
  52. -- MTS memory needed to hold session information for shared server users
  53. -- This query computes a total for all currently logged on users (run
  54. -- during peak period). Alternatively calculate for a single user and
  55. -- multiply by # users.
  56. select sum(value) into mts_mem from v$sesstat s, v$statname n
  57.        where s.statistic#=n.statistic#
  58.        and n.name='session uga memory max';
  59.  
  60. -- Free (unused) memory in the SGA: gives an indication of how much memory
  61. -- is being wasted out of the total allocated.
  62. -- For pre-9i issue
  63. -- select bytes into free_mem from v$sgastat
  64. -- where name = 'free memory';

  65. -- with 9i and newer releases issue
  66. select bytes into free_mem from v$sgastat
  67.         where name = 'free memory'
  68.         and pool = 'shared pool';

  69.  
  70. -- For non-MTS add up object, shared sql, cursors and 20% overhead.
  71. -- Not including cursor_mem because this is included in shared_sql
  72. used_pool_size := round(1.2*(object_mem+shared_sql));
  73.  
  74. -- For MTS mts contribution needs to be included (comment out previous line)
  75. -- used_pool_size := round(1.2*(object_mem+shared_sql+mts_mem));

  76. -- Pre-9i or if using manual SGA management, issue
  77. -- select value into pool_size from v$parameter where name='shared_pool_size';

  78. -- With 9i and 10g and and automatic SGA management, issue
  79. select c.ksppstvl into pool_size from x$ksppi a, x$ksppcv b, x$ksppsv c
  80.      where a.indx = b.indx and a.indx = c.indx
  81.        and a.ksppinm = '__shared_pool_size';
  82.  
  83. -- Display results
  84. dbms_output.put_line ('Obj mem: '||to_char (object_mem) || ' bytes ' || '('
  85. || to_char(round(object_mem/1024/1024,2)) || 'MB)');
  86. dbms_output.put_line ('Shared sql: '||to_char (shared_sql) || ' bytes ' || '('
  87. || to_char(round(shared_sql/1024/1024,2)) || 'MB)');
  88. dbms_output.put_line ('Cursors: '||to_char (cursor_mem+cursor_ovh) || ' bytes '
  89. || '('|| to_char(round((cursor_mem+cursor_ovh)/1024/1024,2)) || 'MB)');
  90. -- dbms_output.put_line ('MTS session: '||to_char (mts_mem) || ' bytes');
  91. dbms_output.put_line ('Free memory: '||to_char (free_mem) || ' bytes ' || '('
  92. || to_char(round(free_mem/1024/1024,2)) || 'MB)');
  93. dbms_output.put_line ('Shared pool utilization (total): '||
  94. to_char(used_pool_size) || ' bytes ' || '(' ||
  95. to_char(round(used_pool_size/1024/1024,2)) || 'MB)');
  96. dbms_output.put_line ('Shared pool allocation (actual): '|| pool_size ||
  97. 'bytes ' || '(' || to_char(round(pool_size/1024/1024,2)) || 'MB)');
  98. dbms_output.put_line ('Percentage Utilized: '||to_char
  99. (round(((pool_size-free_mem) / pool_size)*100)) || '%');
  100. end;
  101. /
  102.  
  103. spool off

  1. SELECT shared_pool_size_for_estimate "Size of Shared Pool in MB",
  2.               shared_pool_size_factor "Size Factor",
  3.               estd_lc_time_saved "Time Saved in sec"
  4.          FROM v$shared_pool_advice;


阅读(842) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~