`
coolsooner
  • 浏览: 1373388 次
文章分类
社区版块
存档分类
最新评论

Tuning the Shared pool(1)

 
阅读更多
Tuning the Shared pool
培训目标:
* Determine the size of an object and pin it in the shared pool.钉在
* Tune the shared pool reserved space
* Describe the user global area and session memory considerations.
* Measure the library cache hit ratio命中率
* List other tuning issues related to the shared pool.
* Measure the dictionary cache hit ratio.
* Set the large pool.


Shared Pool Contents
Database buffer cache
Redo log buffer
Shared pool
Library cache
Data dictionary cache
Large pool
Large pool


Shared Pool
Define by SHARED_POOL_SIZE
10g后有SGA_TARGET,11g后有MEMORY_TARGET,都减轻了管理员负担。
Library cache contains statement text,parsed code,and execution plan.
Data dictionary cache contains definitions for tables,columns,and privileges from the data dictionary tables.
UGA(用在共享模式,dedicate模式不用,就算是共享模式,也把UGA放在large pool中,这也是一种调优的途径,以避免占用shared pool的位置)。


The Library Cache
Used to store SQL statements and PL/SQL blocks that are to be shared by users.
Managed by a least recently used(LRU) algorithm
Used to prevent statements reparsing.
预防句子再解析。
Reports error ORA-04031 if the shared pool is out of free memory.


SQL Sharing Criteria
Oracle automatically determines whether a SQL statement or PL/SQL block being issued is identical to another statement currently in the shared pool.


Oracle performs the following steps for the comparison:
1.The text of the statement issued is compared to existing statements in the shared pool.
2.The text of the statement is hashed.If there is no matching hash value,then the SQL statement does not currently exist in the shared pool,and a hard parse is performed.
输入的语句会被hash处理,出来一个较短的特征值,这样就比较容易比对。
3.If there is a matching hash value for an existing SQL statement in the shared pool,then Oracle compares the text of the matched statement to the text of the statement hashed to see if they are identical.The text of the SQL statements or PL/SQL blocks must be identical,character for character,including spaces,case,and comments.
如果hash值是一样的,则把文本逐个字母比对,甚至空间与大小写也要关注(真要关注空格与大小写吗?)


下面这两个是不能共享相同的SQL执行代码的。
SELECT * FROM employees;
SELECT * FROM Employees;
SELECT * FROM employees;


desc v$sysstat 关于系统的一些统计指标
select * from v$sysstat;看到一行是parse count (hard) 后面列出的是硬解析的次数。


此时用另一个会话以HR/HR连接数据库
drop table t
create table t(id number);
insert into t values(&i);
输入1,2,3。
然后现在看一下硬解析次数,再select * from t where id=1;再看一下,发现硬解析次数加了1。再试验一下空间数目,大小写不同,发现硬解析都会增加。看来大小写与空间数目都挺重要的。


show parameter cursor
alter system set cursor_sharing='exact';
alter system set cursor_sharing='similar';
据说改成similar或force后,两个sql语句只是字面值不一样的话,也可以用相同的shared sql area.
例如select * from t where id=21与select * from t where id=22;


4.在SQL语句中涉及的对象的统计数据,要与存在的语句的对象的统计数据相同,才能重用执行代码。例如,如果两个不同的用户登录了,都输入select * from employees,也不能认为是相同的,因为他们各自的schema下都有employees表。


5.绑定变量,在SQL语句中,一定要match in name,datatype,and length;
下面两条语句因为绑定变量名字不一样,也认为是两条不同的SQL语句。
select * from employees where department_id=:department_id;
select * from employees where department_id=:dept_id;


Use Bind Variables.
分享到:
评论

相关推荐

    使用SQL PROFILE固定SHARED POOL中的执行计划

    将SQL Profile放在SHARED POOL中,意味着每次执行相关SQL语句时,都会使用预定义的执行计划,避免了不必要的解析和计划选择过程,从而提升性能。 要查看和管理SQL Profile,可以使用以下SQL*Plus命令: - `SELECT ...

    oracle performance tuning

    若超过1%,可能需要增大`shared_pool_size`。 ```sql SELECT SUM(pins) "executions", SUM(reloads) "cache misses", SUM(reloads)/SUM(pins) FROM v$librarycache; ``` - **解决方案**:增加共享池的大小...

    Oracle调优简要手册

    1. **Shared Pool Tuning**: - **Shared Pool** 是Oracle SGA(System Global Area)的一部分,它存储解析的SQL语句、数据字典信息和其他共享对象。 - **Gets、Pins和Reloads** 是衡量Shared Pool效率的重要指标...

    oracle性能调优

    如果`reloads/pins`比率大于1%,则可能需要增大`shared_pool_size`,或者检查SQL语句是否引用了无效的对象。 2. **Shared Pool预留大小**:预留大小一般为总大小的10%,但不应超过50%。过大可能导致内存浪费,过小...

    Oracle Tuning的一些总结.docx

    而Shared Pool的大小则影响PL/SQL代码和SQL解析的性能,Java Pool的大小影响Java程序的执行效率,Large Pool则用于大对象和RMAN备份等用途。 除了SGA的优化,SQL语句的优化也是Oracle Tuning的重要环节。这包括选择...

    Oracle_Performance_Tuning

    合理设定SGA大小,调整Buffer Cache、Redo Log Buffer、Shared Pool等组件,可以显著提升数据库性能。 另外,数据库的物理设计也会影响性能。表分区、表空间管理和数据存储方式(如ROW_FORMAT、BLOCK_SIZE等)都...

    Oracle Database 10g Performance Tuning

    - **SGA (System Global Area)**:包括Shared Pool、Buffer Cache等多个组件,合理配置每个组件的大小至关重要。 - **PGA (Program Global Area)**:为会话分配的内存区域,需要根据应用需求调整大小。 - **自动内存...

    oracle tuning总结

    本文主要围绕Oracle Tuning的两个关键方面展开:Oracle数据库的内部调整,特别是Shared Global Area (SGA)的优化,以及应用程序和SQL语句的优化。 1. SGA的设置与优化 SGA是Oracle数据库中一个至关重要的内存区域,...

    Oracle Performance Tuning and Optimization

    7. **数据库缓存策略**:Oracle的Buffer Cache、Redo Log Buffer、Shared Pool等内存区域的大小和使用策略也会影响性能。 8. **并行执行**:通过并行查询和并行DML操作,可以利用多核处理器,加快大数据量操作的...

    Oracle性能调整的十大要点

    Shared Pool Tuning** Shared Pool是SGA的一个重要组成部分,用于存储最近使用过的SQL语句及其执行计划等信息。优化Shared Pool对于提高Oracle数据库性能至关重要。 - **Library Cache Optimization** - **Get ...

    微软内部资料-SQL性能优化2

    The pool is, in effect, a common area of memory shared by all processes. One of the most common uses of non-paged pool is the storage of object handles. For more information regarding “maximums,...

    sql performance tuning

    4. **缓存与内存管理**:优化数据库缓存(如Buffer Cache和Shared Pool)的大小和分配,确保热点数据能常驻内存。 5. **数据库参数调整**:根据系统负载和硬件特性调整各种数据库参数,如pga_aggregate_target、db_...

    sql tuning

    为了提高SQL语句的执行效率,Oracle数据库会将执行过的SQL语句及其执行计划存储在系统全局区(SGA)的共享缓冲池(shared buffer pool)中。这意味着当再次执行相同的SQL语句时,Oracle可以迅速找到之前已经计算好的执行...

    Oracle Architecture and Tuning on AIX

    - **共享池(Shared Pool)**:存储共享SQL语句、数据字典缓存等。 - **PGA(Program Global Area)**:每个服务器进程都有一个PGA,用于存储进程特定的数据和控制信息。 ### 二、AIX配置与调优 #### 4.1 内存和分页 ...

    Oracle 12c Peformance Tuning Recipes

    - Shared Pool 与 Large Pool 的分配策略。 - Java Pool 的配置与优化。 - PGA 与 SGA 的合理设置。 - Automatic Memory Management (AMM) 和 Automatic Shared Memory Management (ASMM) 的使用。 4. **第四章...

    Oracel SQL tuning

    当一个SQL语句被提交给Oracle时,系统会检查共享池(Shared Buffer Pool)中是否存在相同的已解析语句。如果找到精确匹配(包括空格、换行和绑定变量等)的语句,Oracle将重用解析结果和执行计划,避免重复解析,这...

    performance tuning

    调整SGA的各个组件(如Buffer Cache,Redo Log Buffer,Shared Pool)大小,以及限制PGA的使用,都能影响数据库性能。 7. **并行执行与资源调度**: - Oracle的并行执行特性允许大查询或DML操作分布式到多个CPU或...

    Oracle Performance Tuning for 10gR2 Second Edition

    理解这些内存区域的工作方式,以及如何合理配置SGA的各个组件(如Buffer Cache、Redo Log Buffer、Shared Pool等),可以显著提高数据读取速度和减少I/O操作。 查询优化器是决定SQL执行效率的关键组件。书中会深入...

    Performance Tuning --oracle 9i 性能调整与优化

    2. 共享池调整(Shared Pool) 共享池是SGA的一部分,用于缓存SQL语句、PL/SQL代码和数据字典信息。其大小由`SHARED_POOL_SIZE`参数控制。优化共享池涉及以下几个方面: - 计算命中率:通过监控`V$SYSSTAT`中的`...

Global site tag (gtag.js) - Google Analytics