Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "13 Copyright © 2004, Oracle. All rights reserved. Monitoring and Managing Storage."— Presentation transcript:

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

2 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

3 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

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

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

6 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

7 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

8 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;

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

10 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

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

12 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-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

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

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

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

17 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.

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

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

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

21 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

22 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.

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

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

25 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;

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

27 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

28 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;

29 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

30 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

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

32 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;

33 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

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

35 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

36 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

37 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;

38 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;

39 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

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

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

42 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

43 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

44 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

45 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.

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

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

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


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

Similar presentations


Ads by Google