`

《Pro Oracle SQL》Chapter2-2.2 SGA – The Shared Pool

阅读更多

2.2 SGA – The Shared Pool  共享池 (page 53)
    The shared pool is one of the most critical memory components particularly when it comes to how SQL executes. The way you write SQL doesn’t just effect the individual SQL statement itself.  The combination of all SQL that executes against the database has a tremendous effect on overall performance and scalability due to how it affects the shared pool.  
    共享池是最重要的内存组件,特别是它关乎SQL如何执行。你书写SQL的方式不仅只是影响SQL语句本身。在数据库上运行的所有SQL的组合(整体)极大的影响全局性能和扩展性,由于它极大的影响共享池。
    The shared pool is where Oracle caches program data.  Every SQL statement executed will have its
parsed form stored in the shared pool. 
The area within the shared pool where statements are stored is called the library cache.  Even before any statement is parsed, Oracle will check the library cache to see if that same statement already exists there.  If it does exist, then Oracle will retrieve and use the cached information instead of going through all the work to parse the same statement again. The same thing goes for any PL/SQL code you run.  The really nifty part is that no matter how many users may want to execute the same SQL statement, Oracle will typically only parse that statement once and share it among all users who want to use it. Maybe you can see where the shared pool gets its name.
    共享池是Oracle缓存程序数据的地方。每条执行过的SQL语句将会把它的解析形式存储在共享池中。在共享池中存放语句的区域称之为库缓存。 只要之前有解析语句,Oracle将检查库缓存,看是否有相同的语句已经存在。如果存在,Oracle将检索和使用缓存中的信息,而不是再做一遍相同语句的解析工作。对于你运行的任何PL/SQL也是一样的(原理)。真正漂亮的 部分是:不论执行相同SQL语句的用户有多少,Oracle将经典的只解析那条语句一次再把它共享给所有要使用它的用户。你可能能明白“共享池"名字的含义了吧。
    SQL statements you write aren’t the only things stored in the shared pool.  The system parameters
Oracle uses will be stored in the shared pool as well.  In an area called the dictionary cache, Oracle will also store information about all the database objects. 
In general, Oracle stores pretty much everything you could think of in the shared pool.  As you can imagine, that makes the shared pool a very busy and important memory component. 
    你所写的SQL语句不是存放在共享池中的唯一东西。Oracle使用的系统参数也会存放在共享池中。在(共享池中)一处被称之为字典缓存的区域,Oracle也将存储所有数据库对象的信息(在其中)。 一般而言,Oracle把相当多的,你该能想到的,所有东西存入共享池中。可以想象,这使得共享池成为非常忙且重要的内存组件。
    Since the memory area allocated to the shared pool is finite, statements that originally get loaded
may not stay there for very long as new statements are executed.  A Least Recently Used (LRU) algorithm regulates how objects in the shared pool are managed.   To borrow an accounting term, it’s similar to a FIFO (First In First Out) system. The basic idea is that statements that are used most frequently and most currently are what are retained.  Unlike a straight FIFO method, how frequently the same statements are used will effect how long they remain in the shared pool.  If you execute a SELECT statement at 8 A.M.and then execute the same statement again at 4 P.M., the parsed version that was stored in the shared pool at 8 A.M. may not still be there.  Depending on the overall size of the shared pool and how much activity it has between 8 A.M. and 4 P.M., as Oracle needs space to store the latest information throughout the day, it will simply reuse older areas and overlay newer information into them.  But, if you execute a statement every few seconds throughout the day, the frequent reuse will cause Oracle to retain that information over something else that may have originally been stored later than your statement but hasn’t been executed frequently, or at all, since it was loaded.
    由于分配给共享池的内存区是有限的,最初装载的语句可能不会保持在其中,因为新的语句要执行。有一个“最近最少使用”算法控制着如何管理共享池中的对象。 借用一会计术语,它类似于FIFO(先进先出)系统。基本的思想是:保持使用的最多,最近的语句。不同于直接的FIFO方法,同一语句的使用频率将影响到它在共享池中的保持时间。如果你在早上8点执行一SELECT语句,然后在下午4点执行相同的SQL语句,早上8点解析的(SQL语句)版本可能不会存在了。依赖于共享池的整体大小和早上8点到下午4点期间的活动数量,Oracle需要空间存储一天中的最近的信息,它将简单的重用原有的区域和覆盖新信息于其上。但是,如果你在一天中每隔几秒就执行一次(相同的)语句,反复的重用将使得Oracle保持那信息,相比其它那些在你的语句之后(执行)最初被存储但是至装载后,不经常或全然不执行的语句而言。
    One of the things you need to keep in mind as you write SQL is that in order to use the shared pool
most efficiently, statements need to be shareable. 
If every statement you write is unique, you basically defeat the purpose of the shared pool.  The less shareable it is, the more effect you’ll see to overall response times.  I’ll show you exactly how expensive parsing can be in the next section.  
    对于书写SQL而言,你需要记住的一件事是:为了最有效的使用共享池,语句必须是可共享的。 如果你所写的每条语句都是唯一的,你根本性的违背了共享池的(设计)目的。语句的共享性越差,越会影响到你所见的全局响应时间。下一节我将为你准确的展现解析操作如何是这般“昂贵”。

 

 

1
2
分享到:
评论

相关推荐

    oracle性能调整 Shared pool深入分析及性能调整.pdf

    **Shared Pool** 是Oracle数据库实例内存结构SGA(System Global Area)中的一个重要组成部分,主要用于存储共享的数据结构,如SQL语句、PL/SQL代码、执行计划、数据字典缓存等。它对提升数据库性能至关重要,特别是...

    佳能F-789SGA计算器说明书

    佳能F-789SGA计算器说明书,有详细的的该型号的计算器的使用说明。

    oracle sga设置

    2. **Shared Pool**:用于存储共享SQL区域(如解析过的SQL语句和执行计划),以及数据字典缓存等共享数据结构。 3. **Large Pool**:默认情况下不分配空间,主要用于RMAN备份操作或连接管理器等组件使用。 4. **Java...

    ORACLE-SGA.docx

    2. 共享池(SHARED_POOL_SIZE):包含PL/SQL代码、SQL语句及其解析信息,以及数据库连接信息。 3. 大池(LARGE_POOL_SIZE):用于RMAN备份、大对象(LOB)操作和Oracle Parallel Server等。 4. Java池(JAVA_POOL_...

    Oracle 9i 调整SGA性能

    1. 性能监控:使用Oracle的性能分析工具如V$视图,监控SGA各个组件的使用情况,如DB BUFFER CACHE HIT RATIO、SHARED POOL命中率等,以判断是否需要调整。 2. 资源分配:根据数据库的工作负载,合理分配SGA各组件的...

    SGA - ORACLE

    SGA的主要组成部分包括共享池(Shared Pool)、数据缓冲区(Data Buffer Cache)、重做日志缓冲区(Redo Log Buffer)、大型池(Large Pool)、Java池(Java Pool)以及流池(Streams Pool)等。 #### 二、SGA基本概念与内存区...

    oracle-sga结构

    Oracle SGA(System Global Area)是Oracle数据库管理系统中的核心组成部分,它是一个共享内存区域,用于存储数据库运行时所需的各种数据和信息。理解SGA的结构对于优化数据库性能和日常维护至关重要。 SGA主要包含...

    ORACLE SQL性能优化系列

    这块位于系统全局区域 SGA(system global area)的共享池(shared buffer pool)中的内存可以被所有的数据库用户共享。因此,当你执行一个 SQL 语句(有时被称为一个游标)时,如果它和之前的执行过的语句完全相同...

    oracle实例的内存(SGA和PGA)进行调整,优化数据库性

    1. **共享池(Shared Pool)**:用于缓存最近执行的SQL语句和数据定义,包括库缓存和数据字典缓存。 2. **数据缓冲区(Database Buffer Cache)**:缓存从数据文件中检索的数据块,显著提升读写性能。 3. **日志缓冲...

    Oracle运维最佳实践-下.pdf 带书签

    - 使用`DBMS_SHARED_POOL.KEEP`将关键SQL语句保留在Shared Pool中。 - **2.1.25 Library Cache诊断:Lock, Pin以及Load Lock** - Library Cache是Shared Pool的一个重要组成部分。 - 本书详细介绍了如何诊断...

    Oracle-sql-Performance-Tuning-30Tips.rar_oracle_tom kyte

    "Oracle SQL Performance Tuning 39Tips" 提供了由Oracle专家Tom Kyte精心总结的30个SQL优化技巧,这些技巧旨在帮助用户提升数据库查询速度,减少资源消耗,提高系统整体性能。 1. **索引优化**:Tom Kyte强调了...

    Oracle 11g体系-全面详解

    - **User Global Area (UGA)**: 在共享服务器模式下,如果没有配置large pool,则UGA属于SGA的Shared Pool;在专用连接模式时,UGA属于PGA。 - **Database Buffer Cache**: 用于存储从磁盘数据文件中读取的数据。 -...

    Oracle数据库发生ORA-04031错误原因浅析及处理.pdf

    2. Oracle进程在向large pool等池中申请内存失败时产生。 本文主要针对出现的“ORA-04031”错误信息进行简单的分析及处理。“ORA-04031”错误主要是由于数据库高速缓冲中的碎片问题导致数据库不能找到足够大的内存...

    Oracle Sql性能调优.ppt

    同时,也需要对内存使用进行优化,例如给 Oracle 更多内存,SGA 调整、shared_pool 调整等。此外,还需要对 IO 进行优化,例如读性能、写性能等。 3. Oracle SQL 与业务实现 Oracle SQL 是 Oracle 数据库的核心...

    Oracle SQL高级编程

    2.2 SGA-共享池 27 2.3 库高速缓存 28 2.4 完全相同的语句 29 2.5 SGA-缓冲区缓存 32 2.6 查询转换 35 2.7 视图合并 36 2.8 子查询解嵌套 39 2.9 谓语前推 42 2.10 使用物化视图进行查询重写 44 2.11 确定执行计划 ...

    oracle TestKing Oracle 1z0-032V9

    1. **Oracle数据库基础**:包括Oracle数据库架构、数据文件、控制文件、重做日志文件、系统全局区域(SGA)和程序全局区域(PGA)的理解。 2. **数据库实例和启动过程**:学习如何启动和关闭数据库实例,理解实例和...

    oracle share pool学习资料

    Shared Pool 是 Oracle SGA (System Global Area) 中的一个关键组成部分,主要负责存储可共享的数据结构,例如 SQL 语句、执行计划等。通过在 Shared Pool 中缓存这些数据结构,Oracle 能够显著提升数据库性能,尤其...

Global site tag (gtag.js) - Google Analytics