13 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Storage.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Advertisements

11 Copyright © Oracle Corporation, All rights reserved. Managing Tables.
The Architecture of Oracle
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
17 Copyright © 2005, Oracle. All rights reserved. Performing Flashback.
12 Copyright © Oracle Corporation, All rights reserved. Managing Indexes.
Semantec Ltd. Oracle Performance Tuning Boyan Pavlov Indexes Indexes.
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
Managing Schema Objects
Harvard University Oracle Database Administration Session 5 Data Storage.
10 Copyright © 2009, Oracle. All rights reserved. Managing Undo Data.
1 Copyright © 2005, Oracle. All rights reserved. Introduction.
Oracle Database Administration Database files Logical database structures.
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
15 Copyright © 2004, Oracle. All rights reserved. Proactive Maintenance.
Lecture 8 Index Organized Tables Clusters Index compression
Oracle Data Block Oracle Concepts Manual. Oracle Rows Oracle Concepts Manual.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 9 Index Management.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
9 Copyright © 2004, Oracle. All rights reserved. Flashback Database.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Database structure and space Management. Segments The level of logical database storage above an extent is called a segment. A segment is a set of extents.
8 Copyright © 2007, Oracle. All rights reserved. Managing Schema Objects.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
5 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
6 Copyright © 2007, Oracle. All rights reserved. Managing Database Storage Structures.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
13 Copyright © Oracle Corporation, All rights reserved. Maintaining Data Integrity.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
The Self-managing Database: Proactive Space and Schema Object Management Amit Ganesh Director, Data, Space and Transaction Processing Oracle Corporation.
Managing Schema Objects
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Managing Storage.
14 Copyright © 2005, Oracle. All rights reserved. Backup and Recovery Concepts.
Unit 6 Seminar. Indexed Organized Tables Definition: Index Organized Tables are tables that, unlike heap tables, are organized like B*Tree indexes.
6 Copyright © Oracle Corporation, All rights reserved. Backup and Recovery Overview.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
8 Copyright © 2007, Oracle. All rights reserved. Implementing SecureFile LOBs.
Indexes 22 Index Table Key Row pointer … WHERE key = 22.
6 Copyright © 2005, Oracle. All rights reserved. Managing Database Storage Structures.
8 Copyright © Oracle Corporation, All rights reserved. Managing Tablespaces and Data files.
23 Copyright © 2004, Oracle. All rights reserved. Preferring the Past: Flashback.
Oracle Database Architectural Components
15 Copyright © Oracle Corporation, All rights reserved. Managing Users.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
9 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
10 Copyright © 2007, Oracle. All rights reserved. Managing Undo Data.
Data, Space and Transaction Processing
Database structure and space Management
Indexes and Basic Access Methods
Oracle 10g Database Administrator: Implementation and Administration
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Lecture 12 Lecture 12: Indexing.
Managing Indexes.
Index Index.
Alternative Storage Techniques
Presentation transcript:

13 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Storage

13-2 Copyright © 2004, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to: Tune redo writing and archiving operations Issue statements that can be suspended when encountering space condition errors Reduce space-related error conditions through proactively managing tablespace space usage Reclaim wasted space from tables and indexes using the segment-shrink functionality Estimate the size of new tables and indexes Use different storage options to improve performance of queries Rebuild indexes online

13-3 Copyright © 2004, Oracle. All rights reserved. Online Redo Log File Configuration Size redo log files to minimize contention. Provide enough groups to prevent waiting. Store redo log files on separate, fast devices. Monitor the redo log file configuration with: – V$LOGFILE – V$LOG – V$INSTANCE_RECOVERY

13-4 Copyright © 2004, Oracle. All rights reserved.

13-5 Copyright © 2004, Oracle. All rights reserved. Redo Logfile Sizing Advisor

13-6 Copyright © 2004, Oracle. All rights reserved. Increasing the Performance of Archiving Allow the LGWR process to write to a disk different from the one the ARCn process is reading. Share the archiving work during a temporary increase in workload: Increase the number of archive processes. Change archiving speed: – LOG_ARCHIVE_MAX_PROCESSES – LOG_ARCHIVE_DEST_n ALTER SYSTEM ARCHIVE LOG ALL TO

13-7 Copyright © 2004, Oracle. All rights reserved. Resumable Statements A resumable statement: Allows you to suspend large operations instead of receiving an error Gives you a chance to fix the problem while the operation is suspended, rather than starting over Is suspended for the following conditions: –Out of space –Maximum extents reached –Space quota exceeded

13-8 Copyright © 2004, Oracle. All rights reserved. Using Resumable Space Allocation Queries, DML operations, and certain DDL operations can be resumed if they encounter an out-of-space error. A resumable statement can be issued through SQL, PL/SQL, SQL*Loader, or the Oracle Call Interface (OCI). To run a resumable statement, you must first enable resumable statements for your session. ALTER SESSION ENABLE RESUMABLE; INSERT INTO sales_new SELECT * FROM sh.sales; ALTER SESSION DISABLE RESUMABLE;

13-9 Copyright © 2004, Oracle. All rights reserved.

13-10 Copyright © 2004, Oracle. All rights reserved. Resuming Suspended Statements SQL statement EMPLOYEES table Suspended EMPLOYEES table Free space Used block Continue SQL operation AFTER SUSPEND trigger Abort

13-11 Copyright © 2004, Oracle. All rights reserved.

13-12 Copyright © 2004, Oracle. All rights reserved. Proactive Tablespace Monitoring Overview Server-generated alerts inform you that: –Tablespaces are running low on available space –Segments are running out of space Data gathering and reporting provides: –Historical tablespace disk space usage –Segment growth trend analysis

13-13 Copyright © 2004, Oracle. All rights reserved. Tablespace Space Usage Monitoring Read-only and offline tablespaces: Do not set up alerts. Temporary tablespace: Threshold corresponds to space currently used by sessions. Undo tablespace: Threshold corresponds to space used by active and unexpired extents. Tablespaces that can extend automatically: Threshold is based on the maximum file size. MMON 85% Warning 97% Critical Check every 10 min. Alert Cleared

13-14 Copyright © 2004, Oracle. All rights reserved. Edit Tablespace Page

13-15 Copyright © 2004, Oracle. All rights reserved. Segment Advisor Overview

13-16 Copyright © 2004, Oracle. All rights reserved. Shrinking Segments: Overview HWM Shrink operation Data Unused space Data Unused space Reclaimed space

13-17 Copyright © 2004, Oracle. All rights reserved. Shrinking Segments: Considerations Online and in-place operation Applicable only to segments residing in ASSM tablespaces Candidate segment types: –Heap-organized tables and index-organized tables –Indexes –Partitions and subpartitions –Materialized views and materialized view logs Indexes are maintained. Triggers are not fired.

13-18 Copyright © 2004, Oracle. All rights reserved. Database Control and Segment Shrink

13-19 Copyright © 2004, Oracle. All rights reserved. Accessing the Segment Advisor

13-20 Copyright © 2004, Oracle. All rights reserved. Segment Advisor

13-21 Copyright © 2004, Oracle. All rights reserved. Shrinking Segments Using SQL ALTER TABLE employees SHRINK SPACE CASCADE; ALTER … SHRINK SPACE [COMPACT] [CASCADE] TABLEINDEXMATERIALIZED VIEWMATERIALIZED VIEW LOG MODIFY PARTITION ALTER TABLE employees ENABLE ROW MOVEMENT; 1 2 MODIFY SUBPARTITION

13-22 Copyright © 2004, Oracle. All rights reserved. Segment Shrink: Execution Considerations Use compaction only: –To avoid unnecessary cursor invalidation –During peak hours DML operations and queries can be issued during compaction. DML operations are blocked when the HWM is adjusted.

13-23 Copyright © 2004, Oracle. All rights reserved. Segment Resource Estimation

13-24 Copyright © 2004, Oracle. All rights reserved. Growth Trend Report Used by the Segment Advisor Space usage statistics are collected into AWR

13-25 Copyright © 2004, Oracle. All rights reserved. Monitoring Index Space To collect usage statistics regarding an index: To view statistics collected: Rebuild indexes with wastage greater than 20%: To coalesce indexes (alternative to REBUILD ): SQL> EXECUTE dbms_stats.gather_index_stats - > ('OE','CUSTOMERS_PK'); SQL> ALTER INDEX oe.customers_pk REBUILD; SQL> SELECT name, 2 (DEL_LF_ROWS_LEN/LF_ROWS_LEN) * 100 AS wastage 3 FROM index_stats; SQL> ALTER INDEX oe.customers_pk COALESCE;

13-26 Copyright © 2004, Oracle. All rights reserved. Monitoring Index Space Usage Actual Predicted

13-27 Copyright © 2004, Oracle. All rights reserved. Deciding Whether to Rebuild or Coalesce an Index RebuildCoalesce Quickly moves index toCannot move index to another tablespaceanother tablespace Higher costs: Requires moreLower costs: Does not disk spacerequire more disk space Creates new tree, shrinksCoalesces leaf blocks within height if applicablesame branch of tree Enables you to quickly changeQuickly frees up index storage and tablespace leaf blocks for use parameters without having to drop the original index

13-28 Copyright © 2004, Oracle. All rights reserved. Identifying Unused Indexes Use index monitoring to determine whether an index is being used: 1.Enable index monitoring, and clear out any existing index use information. 2.Continue normal database operations. 3.Query the V$OBJECT_USAGE view for usage information. 4. Disable index monitoring at the end of evaluation. SQL> ALTER INDEX emp_job_ix MONITORING USAGE; SQL> ALTER INDEX emp_job_ix NOMONITORING USAGE; SQL> SELECT index_name, used FROM V$OBJECT_USAGE;

13-29 Copyright © 2004, Oracle. All rights reserved. Table access by ROWID Index-Organized Tables Regular table access IOT access Non-key columns Key column Row header

13-30 Copyright © 2004, Oracle. All rights reserved. Index-Organized Tables and Heap Tables Compared to heap tables, IOTs have: –Faster key-based access to table data –Do not duplicate the storage of primary key values –Require less storage –Use secondary indexes and logical rowids –Have higher availability, as table reorganization does not invalidate secondary indexes IOTs have the following restrictions: –Must have a primary key that is not DEFERRABLE –Cannot be clustered –Cannot use composite partitioning –Cannot contain a column of type ROWID or LONG

13-31 Copyright © 2004, Oracle. All rights reserved. Notes

13-32 Copyright © 2004, Oracle. All rights reserved. Creating Index-Organized Tables SQL> CREATE TABLE country 2 ( country_id CHAR(2) 3 CONSTRAINT country_id_nn NOT NULL, 4 country_name VARCHAR2(40), 5 currency_name VARCHAR2(25), 6 currency_symbol VARCHAR2(3), 7 map BLOB, 8 flag BLOB, 9 CONSTRAINT country_c_id_pk 10 PRIMARY KEY (country_id)) 11 ORGANIZATION INDEX 12 TABLESPACE indx 13 PCTTHRESHOLD OVERFLOW TABLESPACE users;

13-33 Copyright © 2004, Oracle. All rights reserved. Segment = SYS_IOT_OVER_n IOT_type = IOT_OVERFLOW Segment_type = TABLE Segment = COUNTRY_C_ID_PK IOT_type = IOT Segment_type = INDEX Index_type = IOT - TOP IOT Row Overflow Remaining part of the row Rows within PCTTHRESHOLD indx tablespace users tablespace

13-34 Copyright © 2004, Oracle. All rights reserved. IOT Row Overflow (notes)

13-35 Copyright © 2004, Oracle. All rights reserved. Querying DBA_TABLES for IOT Information SQL> SELECT table_name, iot_name, iot_type 2 FROM DBA_TABLES; TABLE_NAME IOT_NAME IOT_TYPE COUNTRY IOT SYS_IOT_OVER_2268 COUNTRY IOT_OVERFLOW

13-36 Copyright © 2004, Oracle. All rights reserved. Querying DBA_INDEXES and DBA_SEGMENTS for IOT information SQL> SELECT index_name, index_type, 2 tablespace_name, table_name 2 FROM DBA_INDEXES; INDEX_NAME INDEX_TYPE TABLESPACE TABLE_NAME COUNTRY_C_ID_PK IOT - TOP INDX COUNTRY SQL> SELECT segment_name, tablespace_name, 2 segment_type 3 FROM DBA_SEGMENTS; SEGMENT_NAME TABLESPACE_NAME SEGMENT_TYPE SYS_IOT_OVER_2268 USER TABLE COUNTRY_C_ID_PK INDX INDEX

13-37 Copyright © 2004, Oracle. All rights reserved. Using a Mapping Table SQL> CREATE TABLE country 2 ( country_id CHAR(2) 3 CONSTRAINT country_id_nn NOT NULL 4, country_name VARCHAR2(40) 5, currency_name VARCHAR2(25) 6, currency_symbol VARCHAR2(3) 7, CONSTRAINT country_c_id_pk 8 PRIMARY KEY (country_id)) 9 ORGANIZATION INDEX 10 MAPPING TABLE TABLESPACE users;

13-38 Copyright © 2004, Oracle. All rights reserved. Maintaining a Mapping Table Collect statistics on a mapping table by analyzing the IOT. Query the DBA_INDEXES view to determine the percentage accuracy of the mapping table. Rebuild the mapping table if required, using the ALTER TABLE command. Use the COMPRESS clause of CREATE TABLE or ALTER TABLE for the mapping table. SQL> SELECT index_name, pct_direct_access 2 FROM DBA_INDEXES 3 WHERE pct_direct_access IS NOT NULL;

13-39 Copyright © 2004, Oracle. All rights reserved. Clusters Clustered orders and order_item tables Cluster Key (ORD_NO) 101 ORD_DTCUST_CD 05-JAN-97 R01 PROD QTY A A W ORD_DTCUST_CD 07-JAN-97 N45 PROD QTY A G N Unclustered orders and order_item tables ORD_NOORD_DT CUST_CD JAN-97 R JAN-97 N45 ORD_NOPRODQTY A A G N A W082410

13-40 Copyright © 2004, Oracle. All rights reserved. Cluster Types Index cluster Sorted hash cluster Hash function Hash cluster Hash function

13-41 Copyright © 2004, Oracle. All rights reserved.

13-42 Copyright © 2004, Oracle. All rights reserved. Situations Where Clusters Are Useful CriterionIndex Hash Sorted hash Uniform key distributionXXX Evenly distributed key valuesXX Rarely updated keyXXX Often joined master-detail tablesX Predictable number of key valuesXX Queries using equality predicate on keyXX Data is retrieved in the order it was insertedX

13-43 Copyright © 2004, Oracle. All rights reserved. Sorted Hash Cluster: Example CREATE CLUSTER calls_cluster ( origin_number NUMBER, call_timestamp NUMBER SORT, call_duration NUMBER SORT) HASHKEYS SINGLE TABLE HASH IS origin_number SIZE 50; CREATE TABLE calls ( origin_number NUMBER, call_timestamp NUMBER, call_duration NUMBER, other_info VARCHAR2(30)) CLUSTER calls_cluster( origin_number,call_timestamp,call_duration ); Cluster key Sort key

13-44 Copyright © 2004, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Tune redo writing and archiving operations Issue statements that can be suspended when encountering space condition errors Reduce space-related error conditions through proactively managing tablespace space usage Reclaim wasted space from tables and indexes using the segment shrink functionality Estimate the size of new tables and indexes Use sorted hash clusters Rebuild indexes online

13-45 Copyright © 2004, Oracle. All rights reserved. Practice 13 Overview: Managing Storage This practice covers the following topics: Monitoring index space usage and rebuilding indexes if needed Using the Segment Advisor to shrink the space allocated to a table Using the Segment Space Estimator to determine the amount of space required to create a new table.

13-46 Copyright © 2004, Oracle. All rights reserved.

13-47 Copyright © 2004, Oracle. All rights reserved.

13-48 Copyright © 2004, Oracle. All rights reserved.