`

《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认证专家视频教程-OCP全套教程-共98个视频

    03-042-1-4-sga-shared_pool.mp4 03-042-1-5-sga-data_buffer.mp4 03-042-1-6-sga-log_buffer.mp4 03-042-1-7-sga-large_poolmp4 03-042-1-8-sga-others_pool.mp4 03-042-1-9-bcakground-process.mp4 03-042-1-10-bg...

    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 确定执行计划 ...

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

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

    oracle-sga结构

    oracle sga 结构的讲解,了解oracle的sga结构。

    SGA - ORACLE

    1. 本文系作者的学习总结总(参考文档来自ORACLE官方文档) 2. 介绍了ORACLE中SGA的基本概念与样关内存区的的分配基本原则

    Oracle 体系结构-SGA

    Oracle数据库由两部分组成:实例和数据库 实例是由一块共享内存区域以及一些后台进程组成。 1.SGA SGA为共享内存区域,也叫系统全局区 SGA的特点: -是共享的,是所有使用当前实例的用户都可以读取的内存部分。 -一...

    Oracle11g Memory&Storage Overview

    本ppt较为系统的介绍了Oracle11g的内存与存储管理,主要目录如下: 1.Memory Overview:  --SGA Parameters  --Automatic Shared Memory Management  --Oracle 11g参数设置建议  --Oracle Database Memory ...

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

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

    论文研究-基于SGA假设的2PPM-THMA UWB系统性能分析 .pdf

    基于SGA假设的2PPM-THMA UWB系统性能分析,胡波,,IR-UWB通信系统的多址调制方式通常是脉冲跳时(TH,Time-hopping)与脉位调制(PPM,Pulse Position Modulation)的组合,即TH-PPM调制。这种多址接

    oracle改sga导致数据库启动异常处理办法

    有时改oracle的sga相关值后,重启oracle出现异常。 其实更改sga前掌握好先备份的原则,就能快速恢复

    oracle10g课堂练习I(2)

    课程目标 1-2 建议日程表 1-3 课程目标 1-4 Oracle 产品和服务 1-5 Oracle Database 10 g :“g”代表网格 1-6 Oracle 数据库体系结构 1-8 数据库结构 1-9 Oracle 内存结构 1-10 进程结构 1-12 Oracle 实例...

    Oracle SQL高级编程(资深Oracle专家力作,OakTable团队推荐)--随书源代码

    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 确定...

    cat4500-entservices-mz.122-31.SGA11.bin

    cat4500-entservices-mz.122-31.SGA11.bin

    Oracle 9i 调整SGA性能

    调整SGA以及优化oracle数据库,提高数据库的性能。

    Oracle 性能调整(真正由ORACLE甲骨文出品)

    – 每个查询会耗用2%CPU – 大量的I/O <br> 所以: – 170 meg = 5038 SQL Areas = 131319 x$ksmsp records Keep the Shared_pool_size at 100M or lower (50M if possible). <br> If v...

    更改ORACLE SGA的详细步骤

    更改ORACLE SGA的详细步骤 如果修改后启动不了ORACLE,还原ORACLE初始设置的方法方法: 2、使用dos端登录oracle Sqlplus /nolog; Conn / as sysdba; 3、找 pfile,在 /.../admin/XXX(服务名)/pfile 下,init.ora....

    Oracle SGA

    关于Oracle 中SGA的分配的方式,如何让oracle中的SGAt得到最有利的分配

    oracle sga设置

    oracle sga常用设置,分析,查看等等.

Global site tag (gtag.js) - Google Analytics