1. Trang chủ
  2. » Công Nghệ Thông Tin

Sizing the Buffer Cache doc

37 263 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Sizing the Buffer Cache
Trường học Oracle Corporation
Chuyên ngành Database Management
Thể loại essay
Năm xuất bản 2002
Định dạng
Số trang 37
Dung lượng 343,5 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

All rights reserved.Objectives After completing this lesson, you should be able to do the following: • Employ the buffer cache sizing advisor • Describe how the buffer cache is used by d

Trang 1

Copyright © Oracle Corporation, 2002 All rights reserved.

Sizing the Buffer Cache

Trang 2

5-2 Copyright © Oracle Corporation, 2002 All rights reserved.

Objectives

After completing this lesson, you should be able to do the following:

Employ the buffer cache sizing advisor

Describe how the buffer cache is used by different

Oracle processes

Create and manage different buffer caches

Monitor the use of the buffer caches

Identify and resolve buffer cache

performance problems

Trang 3

5-3 Copyright © Oracle Corporation, 2002 All rights reserved.

Overview

Data files

Checkpoint Queue

.

LRU lists

DBWn

Server

DB_BLOCK_SIZE DB_CACHE_SIZE DB_KEEP_CACHE_SIZE DB_RECYCLE_CACHE_SIZE DB_BLOCK_CHECKSUM

.

Trang 4

5-5 Copyright © Oracle Corporation, 2002 All rights reserved.

Buffer Cache Sizing Parameters

The buffer cache can consist of independent

subcaches for buffer pools and for multiple block sizes.

The DB_BLOCK_SIZE parameter determines the

primary block size, which is the block size used for the system tablespace and the primary buffer caches (recycle, keep, and default).

The following parameters define the sizes of the

caches for buffers for the primary block size:

DB_CACHE_SIZE

DB_KEEP_CACHE_SIZE

DB_RECYCLE_CACHE_SIZE

Trang 5

5-6 Copyright © Oracle Corporation, 2002 All rights reserved.

Dynamic Buffer Cache Advisory Parameter

The buffer cache advisory feature enables and

disables statistics gathering for predicting behavior with different cache sizes.

DBAs can use the information provided by these

statistics to size the buffer cache optimally for a given workload.

The buffer cache advisory is enabled by means of

the DB_CACHE_ADVICE initialization parameter:

This parameter is dynamic and can be changed using ALTER SYSTEM .

Three values are allowed: Off, On, and Ready.

Trang 6

5-7 Copyright © Oracle Corporation, 2002 All rights reserved.

View to Support Buffer Cache Advisory

Buffer cache advisory information is collected in

the v$db_cache_advice view.

The view contains different rows that estimate the

number of physical reads for different caches.

The rows also compute a physical read factor,

which is the ratio of the number of estimated reads

to the number of actual reads.

Trang 7

5-8 Copyright © Oracle Corporation, 2002 All rights reserved.

Using the v$db_cache_advice View

SQL> SELECT size_for_estimate "Cache Size (MB)",

2 buffers_for_estimate "Buffers",

3 estd_physical_read_factor AS

4 "Estd Phys Read Factor",

4 estd_physical_reads "Estd Phys Reads"

10 WHERE name = 'db_block_size')

11 AND advice_status = 'ON';

Trang 8

5-9 Copyright © Oracle Corporation, 2002 All rights reserved.

Using the Buffer Cache Advisory

Trang 9

5-10 Copyright © Oracle Corporation, 2002 All rights reserved.

Checkpoint Queue

.

LRU lists

.

Managing the Database Buffer Cache

4

Trang 10

5-11 Copyright © Oracle Corporation, 2002 All rights reserved.

Checkpoint Queue

.

.

Managing the Database Buffer Cache

Server

Data files

LRU lists

Trang 11

5-12 Copyright © Oracle Corporation, 2002 All rights reserved.

Tuning Goals and Techniques

The v$db_cache_advice view

Bypass the cache for sorting and parallel reads

Trang 12

5-14 Copyright © Oracle Corporation, 2002 All rights reserved.

v$sysstat

Diagnostic Tools

SGA LRU list Checkpoint queue Buffer cache Keep buffer pool Recycle buffer pool v$buffer_pool

v$cache v$buffer_pool_statistics

Statspack Report v$db_cache_advice

Trang 13

5-16 Copyright © Oracle Corporation, 2002 All rights reserved.

Performance Manager

Trang 14

5-17 Copyright © Oracle Corporation, 2002 All rights reserved.

SQL> SELECT name, value

Trang 15

5-18 Copyright © Oracle Corporation, 2002 All rights reserved.

More Buffer Cache Performance Indicators

From v$system_event:

SQL> SELECT event, total_waits

2 FROM v$system_event

3 WHERE event in

4 ('free buffer waits',

5 'buffer busy waits');

EVENT TOTAL_WAITS

-free buffer waits 337

buffer busy waits 3466

Trang 16

5-20 Copyright © Oracle Corporation, 2002 All rights reserved.

Measuring the Cache Hit Ratio

SQL> SELECT 1 - (phy.value - lob.value - dir.value)

2 / ses.value "CACHE HIT RATIO"

3 FROM v$sysstat ses, v$sysstat lob,

4 v$sysstat dir, v$sysstat phy

5 WHERE ses.name = 'session logical reads'

6 AND dir.name = 'physical reads direct'

7 AND lob.name = 'physical reads direct (lob)'

8 AND phy.name = 'physical reads';

Statistic Total Per Per Trans Logon Second - - - - physical reads 15,238 13.0 15,238.0 physical reads direct 863 0.7 863.0 Physical reads direct(lob) 0 0 0 session logical reads 119,376 101.8 119,376.0

From v$sysstat:

From the Statspack report:

Trang 17

5-21 Copyright © Oracle Corporation, 2002 All rights reserved.

Guidelines for Using the Cache Hit Ratio

Hit ratio is affected by data access methods:

Full table scans

Data or application design

Large table with random access

Uneven distribution of cache hits

Trang 18

5-22 Copyright © Oracle Corporation, 2002 All rights reserved.

Buffer Cache Hit Ratio Isn’t Everything

A badly tuned database can still have a hit ratio

Trang 19

5-23 Copyright © Oracle Corporation, 2002 All rights reserved.

Guidelines to Increase the Cache Size

Increase the cache size ratio under the following conditions:

Any wait events have been tuned

SQL statements have been tuned

There is no undue page faulting

The previous increase of the buffer cache

was effective

Low cache hit ratio

Trang 20

5-25 Copyright © Oracle Corporation, 2002 All rights reserved.

Using Multiple Buffer Pools

Trang 21

5-26 Copyright © Oracle Corporation, 2002 All rights reserved.

Defining Multiple Buffer Pools

In the Oracle database:

Individual pools have their own size defined by:

DB_CACHE_SIZE

DB_KEEP_CACHE_SIZE

DB_RECYCLE_CACHE_SIZE

These parameters are dynamic.

Latches are automatically allocated by Oracle

RDBMS.

Trang 22

5-28 Copyright © Oracle Corporation, 2002 All rights reserved.

Enabling Multiple Buffer Pools

CREATE INDEX cust_idx … STORAGE (BUFFER_POOL KEEP …);

ALTER TABLE customer STORAGE (BUFFER_POOL RECYCLE); ALTER INDEX cust_name_idx

STORAGE (BUFFER_POOL KEEP);

Trang 23

5-29 Copyright © Oracle Corporation, 2002 All rights reserved.

KEEP Buffer Pool Guidelines

Tuning goal: Keeping blocks in memory

Size: Holds all or nearly all blocks of the segments

assigned to this pool

Trang 24

5-30 Copyright © Oracle Corporation, 2002 All rights reserved.

RECYCLE Buffer Pool Guidelines

Tuning goal: Eliminate blocks from memory when

transactions are completed

Size: Holds only active blocks

Tool: v$cache

SQL> SELECT owner#, name, count(*) blocks

2 FROM v$cache

3 GROUP BY owner#, name;

OWNER# NAME BLOCKS

-

5 CUSTOMER 147

Trang 25

5-32 Copyright © Oracle Corporation, 2002 All rights reserved.

RECYCLE Buffer Pool Guidelines

Tool: v$sess_io

SQL> SELECT s.username, io.block_gets,

2 io.consistent_gets, io.physical_reads

3 FROM v$sess_io io, v$session s

4 WHERE io.sid = s.sid ;

USERNAME BLOCK_GETS CONSISTENT_GETS PHYSICAL_READS - - - -

HR 21874 2327 1344

Trang 26

5-33 Copyright © Oracle Corporation, 2002 All rights reserved.

Calculating the Hit Ratio for Multiple Pools

SQL> SELECT name, 1 - (physical_reads /

2 (db_block_gets + consistent_gets)) "HIT_RATIO"

Trang 27

5-34 Copyright © Oracle Corporation, 2002 All rights reserved.

Identifying Candidate Pool Segments

Keep pool

Blocks are accessed repeatedly.

Segment size is less than 10% of the default buffer

pool size.

Recycle pool

Blocks are not reused outside of transaction.

Segment size is more than twice the default buffer

pool size.

Trang 28

5-35 Copyright © Oracle Corporation, 2002 All rights reserved.

Dictionary Views with Buffer

Trang 29

5-37 Copyright © Oracle Corporation, 2002 All rights reserved.

Automatic Segment Space Management

Manages free space automatically inside database

segments

Tracks segment free/used space with bitmaps

instead of free lists

Provides better space utilization, especially for the

objects with highly varying size rows

Specified when creating a tablespace

Supported by Oracle Enterprise Manager

Trang 30

5-38 Copyright © Oracle Corporation, 2002 All rights reserved.

Auto-Management of Free Space

Create an auto-managed tablespace:

Create a table that uses auto-management of

EXTENT MANAGEMENT LOCAL

SEGMENT SPACE MANAGEMENT AUTO;

Trang 31

5-39 Copyright © Oracle Corporation, 2002 All rights reserved.

Free Lists

A free list for an object maintains a list of blocks

that are available for inserts.

The number of free lists for an object can be

set dynamically.

Single-CPU systems do not benefit greatly from

multiple free lists.

The tuning goal is to ensure that an object has

sufficient free lists to minimize contention.

Using Automatic Free Space Management

eliminates the need for free lists, thus reducing contention on the database.

Trang 32

5-40 Copyright © Oracle Corporation, 2002 All rights reserved.

Diagnosing Free List Contention

v$waitstat columns: CLASS “segment

header”

COUNT TIME

SGA Data buffer cache

v$system_event columns:

EVENT “buffer busy waits” TOTAL_WAITS

FREELISTS

Trang 33

5-41 Copyright © Oracle Corporation, 2002 All rights reserved.

SGA Data buffer cache

Resolving Free List Contention

Server process

Object ID

Trang 34

5-43 Copyright © Oracle Corporation, 2002 All rights reserved.

Multiple DBWn Processes

Multiple DB Writer (DBWn) processes:

Can be deployed with DB_WRITER_PROCESSES

DISK_ASYNCH_IO parameter.

Trang 35

5-44 Copyright © Oracle Corporation, 2002 All rights reserved.

Multiple I/O Slaves

Provide nonblocking asynchronous I/O requests

Are typically not recommended if asynchronous

I/O is available

Follow the naming convention ora_innn_SID

Trang 36

5-45 Copyright © Oracle Corporation, 2002 All rights reserved.

Tuning DBWn I/O

Tune the DB Writer processes by looking at the value

of the FREE BUFFER WAITS event.

Trang 37

5-46 Copyright © Oracle Corporation, 2002 All rights reserved.

Summary

In this lesson, you should have learned how to:

Employ the buffer cache sizing advisor

Describe how the buffer cache is used by different

Oracle processes

Create and manage different buffer caches

Monitor the use of the buffer caches

Identify and resolve buffer cache

performance problems

Ngày đăng: 15/03/2014, 17:20

TỪ KHÓA LIÊN QUAN

w