||
如果没有实现sql语句共享,也就是硬解析过多时,shared pool没有作用(需要先找library cache,再找free cache,找到合适的trunk后再挂到library cache上,非常耗费时间)。
如果shared pool很大,就会出现free的链、library cache的链也长,这样每次sql执行进来都会消耗很多时间来查找。如果此时再进来新的sql语句,就会出现访问冲突。
10g中允许有多个shared pool,可以设置shared pool空间大于1G。
对于设置shared pool的大小来说,没有一个通用的、普遍适用的值,不同的系统负载需要不同大小的shared pool来管理。通常我们在设置shared pool时,应该遵循“不要太大、也不要太小”的原则,设置一个初始的值,然后让系统正常运行一段时间,在这段时间里,对shared pool的使用情况进行观察监控,最后根据系统的负载得出一个在当前负载下比较合理的值。
通过一些语句,可以查看不同的shared pool,系统的响应时间。
使用如下的SQL语句显示Oracle所建议的shared pool的大小。
SQL> SELECT shared_pool_size_for_estimate “SP”, estd_lc_size “EL”,
estd_lc_memory_objects “ELM”,
2 estd_lc_time_saved “ELT”, estd_lc_time_saved_factor as “ELTS”,
3 estd_lc_memory_object_hits as “ELMO”
4 FROM v$shared_pool_advice;
SP EL ELM ELT ELTS ELMO
--------- ------- ---------- --------- -------- ------------
128 135 12223 8566 0.9993 2980874
160 166 15809 8567 0.9994 2981291
192 197 19167 8570 0.9998 2982322
224 228 22719 8572 1 2982859
256 259 27594 8572 1 2982906
288 292 31436 8572 1 2982917
320 323 36157 8572 1 2982920
352 354 40371 8572 1 2982929
384 385 45019 8572 1 2982937
416 389 46099 8572 1 2982937
448 389 46099 8572 1 2982937
480 389 46099 8572 1 2982937
512 389 46099 8572 1 2982937
以借助v$shared_pool_advice来观察在不同的shared pool尺寸情况下的响应时间(单位是秒)各是多少,如下所示。
SQL> SELECT 'Shared Pool' component, 2 shared_pool_size_for_estimate estd_sp_size, 3 estd_lc_time_saved_factor parse_time_factor, 4 CASE 5 WHEN current_parse_time_elapsed_s + adjustment_s < 0 THEN 6 0 7 ELSE 8 current_parse_time_elapsed_s + adjustment_s 9 END response_time 10 FROM (SELECT shared_pool_size_for_estimate, 11 shared_pool_size_factor, 12 estd_lc_time_saved_factor, 13 a.estd_lc_time_saved, 14 e.VALUE / 100 current_parse_time_elapsed_s, 15 c.estd_lc_time_saved - a.estd_lc_time_saved adjustment_s 16 FROM v$shared_pool_advice a, 17 (SELECT * FROM v$sysstat WHERE NAME = 'parse time elapsed') e, 18 (SELECT estd_lc_time_saved 19 FROM v$shared_pool_advice 20 WHERE shared_pool_size_factor = 1) c); COMPONENT ESTD_SP_SIZE PARSE_TIME_FACTOR RESPONSE_TIME ----------- ------------ ----------------- ------------- Shared Pool 128 0.9993 252.82 Shared Pool 160 0.9994 251.82 Shared Pool 192 0.9998 248.82 Shared Pool 224 1 246.82 Shared Pool 256 1 246.82 Shared Pool 288 1 246.82 Shared Pool 320 1 246.82 Shared Pool 352 1 246.82 Shared Pool 384 1 246.82 Shared Pool 416 1 246.82 Shared Pool 448 1 246.82 Shared Pool 480 1 246.82 Shared Pool 512 1 246.82 |
SGA大小设置:可以在EM管理器中实现。
查看SQL执行计划:
select * from table (dbms_xplan.display_cursor('SQL语句ID'));
查看sql对应的id:select sql_id,sql_text from v$sql where sql_text like '%sql 语句 ';得到之后可以用上面的语句来查看执行计划。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-5-21 19:34
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社