Oracle9i Performance Tuning Chapter 2 Tuning the Buffer Cache.

Slides:



Advertisements
Similar presentations
Office of the Accountant General (A&E) Andhra Pradesh Hyderabad
Advertisements

The Architecture of Oracle
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
9 Copyright © 2006, Oracle. All rights reserved. Tuning the Buffer Cache.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Overview of Database Administrator (DBA) Tools
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 2 Overview of Database Administrator (DBA) Tools.
Oracle Architecture. Instances and Databases (1/2)
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
Basic Storage Concepts and Settings
15 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Memory.
Oracle Online Features - Golfing Instead of Working on Weekends Oracle World 2003 – Session Sep 2003 Denny Wong Consultant Database Services.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Oracle Architectural Components
Harvard University Oracle Database Administration Session 5 Data Storage.
10 Copyright © 2006, Oracle. All rights reserved. Automatic Shared Memory Management.
Oracle Architecture. Database instance When a database is started the current state of the database is given by the data files, a set of background (BG)
Oracle Architecture Client Computer Application Server Oracle Database Lan Or Internet Lan Or Internet Client Server Environment Application By Java or.Net.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
Oracle Overview and Architecture
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
Oracle Documentation Oracle DBA Course (9i, 10g, 11g) Lecture 1: Oracle Architectural Components.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle on Windows Server Introduction to Oracle10g on Microsoft Windows Server.
Basic Oracle Architecture
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Chapter 20 Other Memory Management Topics
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
7202ICT – Database Administration
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
An Oracle server:  Is a database management system that provides an open, comprehensive, integrated approach to information management.  Consists.
James F. Koopmann Implications of Setting Oracle9iR2’s Statistics Collection Level 1 Implications of Setting Oracle9iR2’s Statistical Collection Level.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Using Procedures & Functions Oracle Database PL/SQL 10g Programming Chapter 9.
The Self-Managing Database: Automatic SGA Memory Management Tirthankar Lahiri Senior Manager, Distributed Cache & Memory Management Oracle Corporation.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Outline Introduction to Oracle Memory Structures SGA, PGA, SCA The Specifics of the System Global Area (SGA) Structures Overview of Program Global Areas.
1 Chapter 17 Shared Memory Contention. 2 Overview Specifically talking about SGA – Buffer Cache – Redo Log Buffer Contention in these areas of SGA – Can.
Week 3 Lecture 2 Basic Storage Concepts and Settings.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
1 Logical I/O Julian Dyke Independent Consultant Web Version juliandyke.com © 2005 Julian Dyke.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown President System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2003.
Instance and Media Recovery Structures Supinfo Oracle Lab. 7.
Chapter 1Oracle9i DBA II: Backup/Recovery and Network Administration 1 Chapter 1 Backup and Recovery Overview MSCD642 Backup and Recovery.
7 Copyright © Oracle Corporation, All rights reserved. Instance and Media Recovery Structures.
Oracle9i Performance Tuning Chapter 4 Tuning the Shared Pool Memory.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
What is Oracle ? Oracle is a relational database management system. It is a management system which uses the relational data model. In the relational data.
Dr. Stephan Bühne SAP Solution Center Walldorf Oracle 9i: Features for SAP Which new Oracle 9i features are helpful for a SAP customer? Dr. Stephan Bühne.
4 Copyright © 2004, Oracle. All rights reserved. Managing the Oracle Instance.
Oracle Database Architectural Components
Chapter 21 SGA Architecture and Wait Event Summarized & Presented by Yeon JongHeum IDS Lab., Seoul National University.
Table spaces.
Initialization Parameters
Using Data Dictionary and Dynamic Performance Views
Oracle Architectural Components
Storage Structure and Relationships
Database Performance Tuning and Query Optimization
Oracle Memory Internals
Oracle Architectural Components
Chapter 11 Database Performance Tuning and Query Optimization
ISYS366, Oracle Disk Internals
Presentation transcript:

Oracle9i Performance Tuning Chapter 2 Tuning the Buffer Cache

Chapter 2: Tuning the Buffer Cache2 Chapter Objectives Understand how the buffer cache works Learn how to configure the buffer cache Learn how to configure a database with one or multiple database block sizes Dynamically allocate SGA memory Configure a buffer cache with multiple buffer pools

Chapter 2: Tuning the Buffer Cache3 Chapter Objectives (continued) Understand how automatic table caching works Learn how to use the new Buffer Cache Size Advice Diagnose buffer cache configuration Look inside the buffer cache

Chapter 2: Tuning the Buffer Cache4 Oracle Architecture

Chapter 2: Tuning the Buffer Cache5 Buffer Cache Overview The SGA is the memory structure in which Oracle caches data that is retrieved for: Access Updates Submitted SQL statements Executed PL/SQL blocks Data dictionary definitions Other cache mechanisms The major purpose of the SGA is to enhance data retrieval by placing the most frequently used data in memory rather than retrieving it from disk

Chapter 2: Tuning the Buffer Cache6 Buffer Cache Overview (continued) The SGA consists of the following memory structures: Buffer cache Redo log buffers Shared pool memory Large pool Java pool

Chapter 2: Tuning the Buffer Cache7 Buffer Cache Overview (continued) The buffer cache stores the most frequently accessed Oracle data blocks to reduce disk I/O If data is cached, the Oracle server sends back the data requested without returning to the data files (this is known as a cache hit) If data is not cached, the Oracle server fetches the data from data files in the database based on the execution plan (this is known as a cache miss)

Chapter 2: Tuning the Buffer Cache8 Buffer Cache Overview (continued)

Chapter 2: Tuning the Buffer Cache9 Buffer Cache Overview (continued) The types of buffers are: Default Keep Recycle

Chapter 2: Tuning the Buffer Cache10 Configuring the Buffer Cache Initial configuration can be based on existing databases and types of applications The DB_BLOCK_BUFFERS parameter is deprecated in Oracle9i but is still supported for backward compatibility DB_BLOCK_BUFFERS cannot be allocated dynamically Use DB_CACHE_SIZE to size the buffer DB_CACHE_SIZE can be changed without shutting down the database The Buffer Cache Size Advice feature is enabled only if the DB_CACHE_SIZE parameter is used The SGA_MAX_SIZE parameter sets the maximum size the SGA can grow to

Chapter 2: Tuning the Buffer Cache11 Database with Multiple Block Sizes Buffers support tablespaces with different block sizes than the one set with the DB_BLOCK_SIZE parameter Parameters: DB_2K_CACHE_SIZE DB_4K_CACHE_SIZE DB_8K_CACHE_SIZE DB_16K_CACHE_SIZE DB_32K_CACHE_SIZE SQL> CREATE TABLESPACE TEST_DATA_16K 2 LOGGING 3 DATAFILE 4 'C:\ORACLE\ORADATA\SAM\TEST_DATA_16K.ORA' 5 SIZE 100M 6 BLOCKSIZE EXTENT MANAGEMENT LOCAL 8 / SQL> SELECT TABLESPACE_NAME, BLOCK_SIZE 2 FROM DBA_TABLESPACES;

Chapter 2: Tuning the Buffer Cache12 Dynamic SGA Allocation Use SGA_MAX_SIZE if you need to increase the SGA allocated memory Use V$SGA_DYNAMIC_COMPONENTS to view the size of the major memory structures in the SGA When you are adjusting the size of any memory structure in the SGA, it is decremented or incremented in granules In Oracle9i, a granule is a memory unit

Chapter 2: Tuning the Buffer Cache13 Dynamic SGA Allocation (continued)

Chapter 2: Tuning the Buffer Cache14 Dynamic SGA Allocation (continued)

Chapter 2: Tuning the Buffer Cache15 Configuring Multiple Buffer Pools DB_KEEP_CACHE_SIZE configures memory allocation for the KEEP pool in the buffer cache DB_RECYCLE_CACHE_SIZE configures memory allocation for the RECYCLE pool in the buffer cache Total size of memory for buffers is the sum of the following parameter values: DB_CACHE_SIZE DB_KEEP_CACHE_SIZE DB_RECYCLE_CACHE_SIZE DB_2K_CACHE_SIZE DB_4K_CACHE_SIZE DB_8K_CACHE_SIZE DB_16K_CACHE_SIZE DB_32K_CACHE_SIZE SQL> SELECT SUM(VALUE)/(1024*1024) 2 FROM V$PARAMETER 3 WHERE NAME IN('db_cache_size','db_keep_cache_size', 4 'db_recycle_cache_size', 'db_2k_cache_size', 5 'db_4k_cache_size', 'db_8k_cache_size', 6 'db_16k_cahce_size', 'db_32_cache_size') 7 /

Chapter 2: Tuning the Buffer Cache16 Configuring Multiple Buffer Pools (continued) Cache a table in a specific buffer: SQL> ALTER TABLE DEPARTMENTS 2 STORAGE ( BUFFER_POOL KEEP) 3 / SQL> SELECT /*+ CACHE(CATEGORIES) */ * FROM CATEGORIES / Method 1 Method 2 SQL> ALTER TABLE DEPARTMENTS CACHE; SQL> SELECT TABLE_NAME, CACHE, BUFFER_POOL 2 FROM USER_TABLES 3 ORDER BY TABLE_NAME 4 /

Chapter 2: Tuning the Buffer Cache17 Automatic Table Caching Oracle9i Release 2 has introduced the automatic caching of small tables based on the size of the table Small table: a table is considered small if it is less than 20 blocks or 2% of the total cached blocks Medium table: a table is considered medium if it is more than 20 blocks and less than 10% of the total cached blocks Automatic table caching is based on these criteria, caching statistics, and table scan frequency These criteria do not apply to any table that has the CACHE option enabled

Chapter 2: Tuning the Buffer Cache18 Buffer Cache Advice

Chapter 2: Tuning the Buffer Cache19 Buffer Cache Advice (continued)

Chapter 2: Tuning the Buffer Cache20 Buffer Cache Advice (continued) SQL> SELECT DECODE(SIZE_FACTOR, 1, '==>', null) " ", SIZE_FOR_ESTIMATE CSIZE, TRUNC(SIZE_FACTOR*100)||'%' PERCENT, BUFFERS_FOR_ESTIMATE BUFFERS_EST, ESTD_PHYSICAL_READ_FACTOR E_PHY_READ_FACTOR, ESTD_PHYSICAL_READS E_PHY_READS FROM V$DB_CACHE_ADVICE WHERE NAME = 'DEFAULT' AND ADVICE_STATUS = 'ON' AND BLOCK_SIZE = (SELECT VALUE FROM V$PARAMETER WHERE NAME = 'db_block_size'); CACHE SIZE PERCENT BUFFERS_EST E_PHY_READ_FACTOR E_PHY_READS % % ==> % % % % % %

Chapter 2: Tuning the Buffer Cache21 Buffer Cache Advice (continued)

Chapter 2: Tuning the Buffer Cache22 Buffer Cache Diagnosis Use V$SYSSTAT and V$SESSTAT Buffer cache hit ratio is a percentage of physical reads over logical reads Hit ratio = 1 - (physical reads/(block gets + consistent gets))/100 Physical reads is the total number of data blocks accessed from disk Block gets is the total number of buffers that are obtained for update (means the data block was read for update) Consistent gets is the total number of buffers that are obtained in consistent read (means that the data block that was accessed used the System Change Number (SCN) to determine that the data block being read did not change since the query was submitted) SELECT ROUND( (1 - (PHY.VALUE/(CUR.VALUE + CON.VALUE)))*100, 1)||'%' ratio 2 FROM V$SYSSTAT PHY, V$SYSSTAT CUR, V$SYSSTAT CON 3 WHERE PHY.NAME = 'physical reads' 4 AND CUR.NAME = 'db block gets' 5 AND CON.NAME = 'consistent gets';

Chapter 2: Tuning the Buffer Cache23 Buffer Cache Diagnosis (continued) Buffer cache hit ratio threshold

Chapter 2: Tuning the Buffer Cache24 Buffer Cache Diagnosis (continued) Hit ratio per session SQL> SELECT PHY.SID, 2 S.USERNAME, (PHY.VALUE)/(CUR.VALUE + CON.VALUE) BUFFER_HITRATIO 4 FROM V$SESSTAT PHY, V$SESSTAT CUR, V$SESSTAT CON, 5 V$STATNAME S1, V$STATNAME S2, V$STATNAME S3, 6 V$SESSION S 7 WHERE S1.NAME = 'physical reads' 8 AND S2.NAME = 'db block gets' 9 AND S3.NAME = 'consistent gets' 10 AND PHY.STATISTIC# = S1.STATISTIC# 11 AND CUR.STATISTIC# = S2.STATISTIC# 12 AND CON.STATISTIC# = S3.STATISTIC# 13 AND CUR.VALUE <> 0 14 AND CON.VALUE <> 0 15 AND PHY.SID = CUR.SID 16 AND PHY.SID = CON.SID 17 AND PHY.SID = S.SID 18 /

Chapter 2: Tuning the Buffer Cache25 Buffer Cache Diagnosis (continued) Buffer pool statistics are shown using the performance dynamic view V$BUFFER_POOL_STATISTICS Block size buffer hit ratio SQL> COLUMN RATIO HEADING "Buffer Cache Hitratio" FORMAT A30 SQL> COLUMN NAME HEADING 'Buffer Pool' FORMAT A15 SQL> COLUMN BLOCK_SIZE HEADING 'Block SQL> SELECT Size' SELECT NAME, 2 BLOCK_SIZE, 3 ROUND( (1 - (PHYSICAL_READS/ 4 (DB_BLOCK_GETS + CONSISTENT_GETS)))*100) || '%' ratio 5 FROM V$BUFFER_POOL_STATISTICS 6 / SQL> SELECT BLOCK_SIZE, 2 ROUND( (1 - AVG((PHYSICAL_READS/ 3 (DB_BLOCK_GETS + CONSISTENT_GETS))))*100) || '%' ratio 4 FROM V$BUFFER_POOL_STATISTICS 5 GROUP BY BLOCK_SIZE 6 /

Chapter 2: Tuning the Buffer Cache26 Inside the Buffer Cache Use the V$BH view to: Query the view for a list of data objects residing in the buffers and the number of data blocks in use See how many blocks are modified (dirty) and how many are free or read Inspect blocks that have been rewritten and re-read in an Oracle Real Application Cluster configuration Find out more about which data files or tablespaces being accessed most often and how many buffers they use

Chapter 2: Tuning the Buffer Cache27 Inside the Buffer Cache (continued)

Chapter 2: Tuning the Buffer Cache28Summary The buffer cache is a memory structure of the SGA The buffer cache facilitates faster access to data, because when data is retrieved from a disk, the cost to performance is high The Least Recent Used algorithm ages out the least retrieved and changed blocks of data from the buffer The buffer cache consists of three major internal structures: the Default buffer pool, Keep buffer pool, and Recycle buffer pool The DB_CACHE_SIZE parameter configures the size of the buffer cache