-
A server process cannot find clean buffers for reading new blocks into the database buffer cache.
-
The database must advance the checkpoint, which is the position in the redo thread from which instance recovery must begin.
-
Tablespaces are changed to read-only status or taken offline.
SELECT size_for_estimate, buffers_for_estimate, estd_physical_read_factor, estd_physical_reads FROM V$DB_CACHE_ADVICE WHERE name = 'DEFAULT' AND block_size = (SELECT value FROM V$PARAMETER WHERE name = 'db_block_size') AND advice_status = 'ON';
根據執行上面語句,我們可以看到當buffer cache 爲272M時,而不是304M時,物理讀會增加1.74倍或者是74%,所以不建議設置buffer cache爲212M。
當buffer cache 增加到334M時,物理讀會減少7%,所以當SGA_MAX設置允許的情況下,建議增加buffer cache的大小。
Estd Phys Estd Phys Cache Size (MB) Buffers Read Factor Reads ---------------- ------------ ----------- ------------ 30 3,802 18.70 192,317,943 10% of Current Size 60 7,604 12.83 131,949,536 91 11,406 7.38 75,865,861 121 15,208 4.97 51,111,658 152 19,010 3.64 37,460,786 182 22,812 2.50 25,668,196 212 26,614 1.74 17,850,847 243 30,416 1.33 13,720,149 273 34,218 1.13 11,583,180 304 38,020 1.00 10,282,475 Current Size 334 41,822 .93 9,515,878 364 45,624 .87 8,909,026 395 49,426 .83 8,495,039 424 53,228 .79 8,116,496 456 57,030 .76 7,824,764 486 60,832 .74 7,563,180 517 64,634 .71 7,311,729 547 68,436 .69 7,104,280 577 72,238 .67 6,895,122 608 76,040 .66 6,739,731 200% of Current Size
計算buffer cache 的命中率
1.計算buffer cache 命中率所需要的一些資料如下
Statistic | Description |
---|---|
Number of times a consistent read was requested for a block from the buffer cache. | |
Number of times a CURRENT block was requested from the buffer cache. | |
Total number of data blocks read from disk into buffer cache. |
Example 7-1 Calculating the Buffer Cache Hit Ratio
SELECT NAME, VALUE FROM V$SYSSTAT WHERE NAME IN ('db block gets from cache', 'consistent gets from cache', 'physical reads cache');
Using the values in the output of the query, calculate the hit ratio for the buffer cache with the following formula:
1 - (('physical reads cache') / ('consistent gets from cache' + 'db block gets from cache'))
計算命中率的sql 如下
select db_block_gets,consistent_gets,physical_read,1 - (physical_read / (db_block_gets + consistent_gets)) from ( SELECT max(decode(name, 'db block gets from cache', value, null)) as db_block_gets, max(decode(name, 'consistent gets from cache', value, null)) as consistent_gets, max(decode(name, 'physical reads cache', value, null)) as physical_read FROM V$SYSSTAT WHERE NAME IN ('db block gets from cache','consistent gets from cache','physical reads cache') );
The following query counts the number of blocks for all segments that reside in the buffer cache at that point in time. Depending on buffer cache size, this might require a lot of sort space.
COLUMN OBJECT_NAME FORMAT A40 COLUMN NUMBER_OF_BLOCKS FORMAT 999,999,999,999 SELECT o.OBJECT_NAME, COUNT(*) NUMBER_OF_BLOCKS FROM DBA_OBJECTS o, V$BH bh WHERE o.DATA_OBJECT_ID = bh.OBJD AND o.OWNER != 'SYS' GROUP BY o.OBJECT_NAME ORDER BY COUNT(*);
Method 2
Use the following steps to determine the percentage of the cache used by an individual object at a given point in time:
Find the Oracle Database internal object number of the segment by entering the following query:
SELECT DATA_OBJECT_ID, OBJECT_TYPE FROM DBA_OBJECTS WHERE OBJECT_NAME = UPPER('segment_name');
Because two objects can have the same name (if they are different types of objects), use the
OBJECT_TYPE
column to identify the object of interest.Find the number of buffers in the buffer cache for
SEGMENT_NAME
:SELECT COUNT(*) BUFFERS FROM V$BH WHERE OBJD = data_object_id_value;
where
data_object_id_value
is from step 1.Find the number of buffers in the instance:
SELECT NAME, BLOCK_SIZE, SUM(BUFFERS) FROM V$BUFFER_POOL GROUP BY NAME, BLOCK_SIZE HAVING SUM(BUFFERS) 0;
Calculate the ratio of buffers to total buffers to obtain the percentage of the cache currently used by
SEGMENT_NAME
:% cache used by segment_name = [buffers(Step2)/total buffers(Step3)]
列名 | 數據類型 | 說明 |
---|---|---|
ID |
NUMBER |
緩衝池標識號(從1到8,1-6對應於DB_nK_CACHE_SIZE,DB_CACHE_SIZE與系統標準塊尺寸的序號相關,如DB_BLOCK_SIZE爲8K,則DB_CACHE_SIZE的標識號爲3(2,4,8…)。7是DB_KEEP_CACHE_SIZE,8是DB_RECYCLE_CACHE_SIZE) |
NAME |
VARCHAR2(20) |
緩衝池名稱 |
BLOCK_SIZE |
NUMBER |
該池中的緩衝區的塊大小(以字節爲單位)。可能的值:標準塊大小,2的冪非標準的塊大小, 2048 , 4096 , 8192 ,16384 , 32768 . |
ADVICE_STATUS |
VARCHAR2(3) |
建議器狀態:ON表示建議器在運行,OFF表示建議器已經關閉。當建議器關閉了,視圖中的數據是上一次打開所統計得出的 |
SIZE_FOR_ESTIMATE |
NUMBER |
預測性能數據的Cache大小(M爲單位) |
SIZE_FACTOR |
NUMBER |
預測的Cache大小因子(即與當前大小的比例) |
BUFFERS_FOR_ESTIMATE |
NUMBER |
預測性能數據的Cache大小(緩衝塊數) |
ESTD_PHYSICAL_READ_FACTOR |
NUMBER |
這一緩衝大小時,物理讀因子,它是如果緩衝大小爲SIZE_FOR_ESTIMATE時,建議器預測物理讀數與當前實際物理讀數的比率值。如果當前物理讀數爲0,這個值爲空。 |
ESTD_PHYSICAL_READS |
NUMBER |
如果緩衝大小爲SIZE_FOR_ESTIMATE時,建議器預測物理讀數。 |
ESTD_PHYSICAL_READ_TIME |
NUMBER |
當緩衝池的大小爲size_for_estimate時需要的物理讀的時間。 |
ESTD_PCT_OF_DB_TIME_FOR_READS |
NUMBER |
當緩衝池爲size_for_estimate是物理讀所消耗時間的百分比 |
ESTD_CLUSTER_READS |
NUMBER |
爲讀取的數據塊的總數。只對RAC有效 |
ESTD_CLUSTER_READ_TIME |
NUMBER |
讀取花費的總時間。只對rac有效 |