启动instance:1、分配内存空间SGA

2、启动后台进程

内存结构:1、SGA

2、PGA

3、UGA

4、Software code areas

SGA components:1、Database Buffer Cache

2、Redo Log Buffer

3、Shared Pool

4、Large Pool

5、Java Pool

6、Streams Pool

7、Fixed SGA

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Database Buffer Cache(数据库快速缓存):

Database Buffer Cache存储data files中data blocks的copies.全部并行连接同一个数据库instance的用户能够共享訪问buffer Cache.

1、Database Buffer Cache的长处:

a、Optimize Physical I/O(优化物理I/O)

数据库将数据更新写到buffer cache中,将进行更新的SQL语句写入redo log buffer中,当运行commit之后,不马上把buffer cache中的数据写入disk,而是将redo log buffer中的数据写入磁盘。Database writer(DBW) performslazy writes in the background.

b、Keep frequently accessed blocks in the buffer cache and write infrequently accessed blocks to disk(保持频繁使用的blocks在buffer cache,不频繁使用的写进disk)

When Database Smart Flash Cache (flash cache) is enabled, part of the buffer cache can reside in the flash cache. This buffer cache extension is stored on a flash disk device,
which is a solid state storage device that uses flash memory. The database can improve performance by caching buffers in flash memory instead of reading from magnetic disk.

2、Buffer States(缓冲区状态):

a、Unused

当前没有被使用的buffer,能够被database使用。

b、Clean

buffer之前被使用,如今存在一个时间点的一致性读版本号,database能够pin缓存中的块而且reuse
it.

c、Dirty

The buffer contain modified data that has not yet been written to disk. The database must checkpoint the block before reusing it.

----------------

每一个buffer都有access mode:pined或者free(即unpined),多个session不能同一时候改动同一个pined buffer.

The database uses a sophisticated algorithm to make buffer access efficient. Pointers to dirty and nondirty buffers exist on the sameleast recently used (LRU)
list, which has a hot end and cold end. Acold
buffer is one that has not been recently used. Ahot buffer is frequently accessed and has been recently used.

3、Buffer Modes:

a、Current Mode

A current mode get, also called a
db block get, is a retrieval of a block as it currently appears in the buffer cache.

b、Consistent Mode

A
consistent read get is a retrieval of a read-consistent version of a block. This retrieval may use undo data.

4、Buffer I/O(logical I/O&physical I/O):

logical I/O即buffer I/O,读取或写入buffer cache中的buffers。当在buffer cache中找不到数据时就会发生physical I/O,physical I/O 把flash cache或者disk中的数据copy到cache buffer,再通过logical I/O从cache buffer中读取数据。

a、Buffer Writes

database writer(DBW)进程会定期地将cold、dirty buffers写入disk(即:将LRU队列的cold end的buffers写入disk)。

DBWn在下面情况下会把buffers写入disk:

1:服务进程在把new blocks读入database buffer cache中时找不到clean buffer.

假设unused buffers数量降到小于内部临界值,而且clean buffers被请求时,DBWn会将cold、dirty buffers写入disk。

数据库用LRU算法来决定把哪个dirty buffer中的数据写入disk。数据库把LRU 队列cold end的dirty buffer 从LRU队列移除,并移到write queue。DBWn 将write queue的buffer写入到disk(using multiblock writes if possible)。这样的机制使得dirty buffers和clean buffers变得可用。

2:The database must advance the checkpoint,which is the position in the redo thread from which instance recovery must begin.

3:Tablespace are changed to read-only status or taken offline.

b、Buffer Reads

1:Flash casche disabled

The database re-uses each clean buffer as needed, overwriting it. If the overwritten buffer is needed later, then the database must read it from magnetic disk.

2:Flash cache enabled

DBWn能够把clean buffer的body写入flash cache,这样能够使cache buffer中的空间重用。数据库把buffer header放入LRU list中。当buffer再次被请求的时候,数据库能够从flash cache中读取,而不是磁盘。

当一个client进程请求buffer时,The search order is as follows:

1:server进程search整个buffer cache

2:server进程search flah cache LRU list中的buffer header

3:将disk数据copy到buffer cache(物理读),从buffer cache读取数据(逻辑读)

注:假设在步骤1或2找到buffer则称为cache hit,没有找到称为cache miss

data file 和 temp file都能够发生physical reads。data file物理读之后还要进行logical I/O。temp file绕过buffer cache,物理读之后不发生logical I/O。(当内存不够时数据库强制将数据写入temporary table)

c、Buffer Touch Count

假设一个buffer is pinned而且上次添加计数是在3秒钟曾经,则touche count添加一个计数。假设一个buffer is pinned,但上次添加计数没有超过3秒,则touche count不曾加计数,保持原值(即看做一次touch)。

假设LRU list cold端的buffer的touch count值比較大,则次cold buffer会被移到hot end。假设LRU list cold端的touch count值比較小,then the buffer ages out of the cache.

d、Buffers and Full Table Scans

当从disk把数据写入buffers时,数据库会把buffers插入到the middle of the LRU list。这样的情况下,full table scan可能会引发一个问题:如果表中的total block size比buffer cache的size大,全表扫描会clean out the buffer cache,preventing the database from maintaining a cache of frequently accessed blocks。所以full table
scan这样的情况和其它的处理方式不一样,当为full table scan时,buffer cache中的blocks能够马上被reuse。

5、Buffer Pools:

A
buffer pool is a collection of buffers. The database buffer cache is divided into one or more buffer pools.

You can manually configure separate buffer pools that either keep data in the buffer cache or make the buffers available for new data immediately after using the data blocks.
You can then assign specific schema objects to the appropriate buffer pool to control how blocks age out of the cache.

The possible buffer pools are as follows:

  • Default pool

    This pool is the location where blocks are normally cached. Unless you manually configure separate pools, the default pool is the only buffer pool.

  • Keep pool

    This pool is intended for blocks that were accessed frequently, but which aged out of the default pool because of lack of space. The goal of the keep buffer pool is to retain objects in memory, thus avoiding I/O operations.

  • Recycle pool

    This pool is intended for blocks that are used infrequently. A recycle pool prevent objects from consuming unnecessary space in the cache.

数据库有标准的block size。在创建tablespace的时候能够指定和标准块大小不一样的block size。每个不是默认block size的tablespace有自己的pool。这些pool的管理和default pool的管理方式同样。

Memory Architecture-SGA-Database Buffer Cache的更多相关文章

  1. Oracle优化 -- 关于Database Buffer Cache相关参数DB_CACHE_SIZE的优化设置

    select size_for_estimate, buffers_for_estimate ,ESTD_PHYSICAL_READ_factor,ESTD_PHYSICAL_READS from v ...

  2. Multiple Database Block Sizes and the Buffer Cache

    In oracle 10g we can have multiple block sizes at the same time. When a tablespace is created we can ...

  3. Buffer cache 的调整与优化

    Buffer cache 的调整与优化 -============================== -- Buffer cache 的调整与优化(一) --==================== ...

  4. [转载]Buffer cache的调整与优化

    Buffer Cache是SGA的重要组成部分,主要用于缓存数据块,其大小也直接影响系统的性能.当Buffer Cache过小的时候,将会造成更多的free buffer waits事件.下面将具体描 ...

  5. Tuning 04 Sizing the Buffer Cache

    Buffer Cache 特性 The buffer cache holds copies of the data blocks from the data files. Because the bu ...

  6. 相克军_Oracle体系_随堂笔记005-Database buffer cache

    本章主要阐述SGA中的Database buffer cache. Buffer cache { 1.pin (读写瞬间的状态) 2.clean 3.dirty 4.unused } --Databa ...

  7. buffer cache —— buffer busy waits/read by other session

    oracle提供非常精确.有效的row level lock机制,多个用户同时修改数据时,为了保护数据,以块为单位挂起锁的情况不会发生.但这不太正确.以块为单位的锁虽然不存在,但正因为oracle I ...

  8. ORACLE性能优化- Buffer cache 的调整与优化

    Buffer Cache是SGA的重要组成部分,主要用于缓存数据块,其大小也直接影响系统的性能.当Buffer Cache过小的时候,将会造成更多的 free buffer waits事件. 下面将具 ...

  9. buffer cache 深度解析

    本文首先详细介绍了oracle中buffer cache的概念以及所包含的内存结构.然后结合各个后台进程(包括DBWRn.CKPT.LGWR等)深入介绍了oracle对于buffer cache的管理 ...

随机推荐

  1. Hadoop学习之HBase和Hive的区别

    Hive是为简化编写MapReduce程序而生的,使用MapReduce做过数据分析的人都知道,很多分析程序除业务逻辑不同外,程序流程基本一样.在这种情况下,就需要Hive这样的用户编程接口.Hive ...

  2. sql server 修改表自增列的值

    Create PROCEDURE [dbo].[SP_UpdateIdentityId] ( ) , @beforeId INT , @afterId INT ) AS BEGIN IF @befor ...

  3. django学习之Model(五)MakingQuery

    接着上篇. 10-一次更新多个对象 有时想要对QuerySet中的所有对象的某一个field来设定一个值,这时候可以像下边这样用update(): # Update all the headlines ...

  4. JDK的目录结构及结构图

    -bin目录: JDK开发工具的可执行文件 -lib目录: 开发工具使用的归档包文件 -jre: Java 运行时环境的根目录,包含Java虚拟机,运行时的类包和Java应用启动器,         ...

  5. DelphiXe5中的双向绑定(使用使用TBindScope和TBindExpression,并覆盖AfterConstruction函数)

    在Delphi下等这一功能很久了,虽然C#下早已实现了这一功能.但是在Dephi下尝试这项功能时还是有些许的激动.闲言少絮,直接上代码. unit BindingDemo; interface use ...

  6. o怎么样racle输入dmp数据库文件

    Oracle进出口数据imp/exp等价物oracle数据恢复和备份. exp命令可以从远程数据库传输数据server出到本地的dmp文件,imp命令能够把dmp文件从本地导入到远处的数据库serve ...

  7. hdu 2777(线段树)

    这道题是看了别人的思路才做出来的. 刚看完这道题没什么思路,线段的长度是10^5,操作指令数是10^5,还要记录不同颜色种类数,觉着怎么写肯定都是要超时.我当时在节点里增加了一个数组记录已经出现的颜色 ...

  8. javascript绑定事件

    本质:不同的库或者工具中总是封装了不同的事件绑定形式,但是究其根源,还是IE事件模型和W3C事件模型不同的处理方式 1)W3C事件模型:支持事件捕捉和冒泡 addEventListener('type ...

  9. hdu 2203亲和串 (kmp)

    #include<cstdio>#include<iostream>#include<cstring>#include<string>using nam ...

  10. Windows 配置JAVA的环境变量

    Java是由Sun公司开发的一种应用于分布式网络环境的程序设计语言,Java语言拥有跨平台的特性,它编译的程序能够运行在多种操作系统平台上,可以实现“一次编写,到处运行”的强大功能. 工具/原料 JD ...