You are on page 1of 36

11

Managing Storage
Copyright 2008, Oracle. All rights reserved.

Space

Objectives

After completing this lesson, you should be able to: Describe how the Oracle database automatically manages space Proactively monitor and manage tablespace space usage se the Segment Advisor !eclaim wasted space from tables and inde"es by using the segment shrin# functionality Manage resumable space allocation Describe the concepts of transportable tablespaces and databases
11 - 2 Copyright 2008, Oracle. All rights reserved.

Management Proactive Monitoring Seg$ Advisor % Seg$Shrin# !esumable Allocation &ransportable &'S and D'

Space Management: Overview


Space is automatically managed by the Oracle database$ (t generates alerts about potential problems and recommends possible solutions$ )eatures include: Oracle Managed )iles *OM)+ )ree,space management with bitmaps *-locally managed.+ and automatic data file e"tension Proactive space management *default thresholds and server,generated alerts+ Space reclamation *shrin#ing segments, online table redefinition+ /apacity planning *growth reports+

11 - 3

Copyright 2008, Oracle. All rights reserved.

)ree Space Management


'M' 'M' 'M' 'M' 'M' 'M' 2 2 2 2 2 2 2 2 2 2 'M'

Segment
11 - 4 Copyright 2008, Oracle. All rights reserved.

{
0"tent

Data bloc#

Automatic 0nabled by the use of locally managed tablespaces &rac#ed by bitmaps in segments 'enefits: More fle"ible space utili1ation !un,time adjustment Multiple process search of 'M's

&ypes of Segments
A segment is a set of e"tents allocated for a certain logical structure$ &he different types of segments are:
Data segment (nde" segment &emporary segment !ollbac# segment

Segments are dynamically allocated by the database$

11 - 5

Copyright 2008, Oracle. All rights reserved.

Allocating 0"tents
Searching the data file3s bitmap for the re4uired number of adjacent free bloc#s Si1ing e"tents with storage clauses:
UNIFORM AUTOALLOCATE

5iewing e"tent map Obtaining deallocation advice

11 - !

Copyright 2008, Oracle. All rights reserved.

'loc# Space Management

PCTFREE = 10 )S6 )S7 )S8

FS1 FS2 (nserts, updates FS3 FS4 )ull bloc#


11 - "

Deletes

Deletes

)ull bloc#

Copyright 2008, Oracle. All rights reserved.

!ow /haining and Migration


0"ample: On update: !ow length increases, e"ceeding the available free space in the bloc#$ Data needs to be stored in a new bloc#$ Original physical identifier of row *ROWID+ is preserved$ &he Oracle database needs to read two bloc#s to retrieve data$ &he Segment Advisor finds segments containing the migrated rows$

Old Origi#al $loc% &ith poi#ter to 'igrated ro&

(e& data

11 - 8

Copyright 2008, Oracle. All rights reserved.

Proactive &ablespace Monitoring

Space Management 9 Proactive $ Monitoring Seg$ Advisor % Seg$Shrin# !esumable Allocation &ransportable &'S and D'

11 - )

Copyright 2008, Oracle. All rights reserved.

&hresholds and !esolving Space Problems


>?< full or ; M' left critical :;< full or 8== M' left warning @ocally managed tablespace

Alert
D'A !esolve space problem

!esolve space problem by: Adding or resi1ing data file Setting AUTOEXTEND ON Shrin#ing objects !educing UNDO_RETENTION /hec#ing for long,running 4ueries in temporary tablespaces
11 - 10 Copyright 2008, Oracle. All rights reserved.

Monitoring &ablespace Space sage


/hec# every 8= min$ Alert Alert >?< /ritical :;< Barning /leared /leared

MMOA

!ead,only and offline tablespaces: Do not set up alerts$ &emporary tablespace: &hreshold corresponds to space currently used by sessions$ ndo tablespace: &hreshold corresponds to space used by active and une"pired e"tents$ Autoe"tensible files: &hreshold is based on the ma"imum file si1e$
Copyright 2008, Oracle. All rights reserved.

11 - 11

Shrin#ing Segments

Space Management Proactive Monitoring 9 Seg$ Advisor % Seg$Shrin# !esumable Allocation &ransportable &'S and D'

CBM

ALTER TABLE employees SHRIN

SPACE COMPACT!

CBM

DM@ operations and 4ueries can be issued during compaction$

ALTER TABLE employees SHRIN

SPACE!

CBM

DM@ operations are bloc#ed when the CBM is adjusted$


11 - 12 Copyright 2008, Oracle. All rights reserved.

!esults of Shrin# Operation


(mproved performance and space utili1ation (nde"es maintained &riggers not e"ecuted Aumber of migrated rows may be reduced !ebuilding secondary inde"es on (O&s recommended
(nde"

&able

Shrin#

D'A

&riggers not e"ecuted


11 - 13 Copyright 2008, Oracle. All rights reserved.

Space !eclamation with ASSM


Online and in,place operation Applicable only to segments residing in ASSM tablespaces /andidate segment types:
Ceap,organi1ed tables and inde",organi1ed tables (nde"es Partitions and subpartitions Materiali1ed views and materiali1ed view logs

11 - 14

Copyright 2008, Oracle. All rights reserved.

Segment Advisor: Overview

11 - 15

Copyright 2008, Oracle. All rights reserved.

Segment Advisor

11 - 1!

Copyright 2008, Oracle. All rights reserved.

*eg'e#t Advisor +,ll (otes -age

11 - 1"

Copyright 2008, Oracle. All rights reserved.

(mplementing !ecommendations

11 - 18

Copyright 2008, Oracle. All rights reserved.

Database /ontrol and Segment Shrin#

11 - 1)

Copyright 2008, Oracle. All rights reserved.

Shrin#ing Segments by sing SD@


ALTER " SHRIN
TABLE #O%ERFLOW$ INDEX

SPACE #CASCADE$
MATERIALI&ED %IEW LO'

MATERIALI&ED %IEW

MODIF( PARTITION

MODIF( SUBPARTITION

MODIF( LOB

ALTER TABLE employees ENABLE ROW MO%EMENT! ALTER TABLE employees SHRIN SPACE CASCADE!

8 6
SPACE,!7

ALTER TABLE employees MODIF( LOB)*es+me, )SHRIN ALTER TABLE employees O%ERFLOW SHRIN SPACE!

11 - 20

Copyright 2008, Oracle. All rights reserved.

Managing !esumable Space Allocation

A resumable statement: 0nables you to suspend large operations instead of receiving an error Fives you a chance to fi" the problem while the operation is suspended, rather than starting over (s suspended for the following conditions:
Out of space Ma"imum e"tents reached Space 4uota e"ceeded

Space Management Proactive Monitoring Seg$ Advisor % Seg$Shrin# 9 !esumable Allocation &ransportable &'S and D'

11 - 21

Copyright 2008, Oracle. All rights reserved.

sing !esumable Space Allocation


Dueries, DM@ operations, and certain DD@ operations can be resumed if they encounter an out,of,space error$ A resumable statement can be issued through SD@, P@GSD@, SD@H@oader, or the Oracle /all (nterface *O/(+$ &o run a resumable statement, you must first enable resumable statements for your session$

ALTER SESSION ENABLE RESUMABLE! INSERT INTO s-les_.e/ SELECT 0 FROM s12s-les! ALTER SESSION DISABLE RESUMABLE!
11 - 22 Copyright 2008, Oracle. All rights reserved.

.si#g /es,'a$le *pace Allocatio# +,ll (otes -age

11 - 23

Copyright 2008, Oracle. All rights reserved.

!esuming Suspended Statements


8
SD@ statement )ull table

Suspended /ontinue SD@ operation &able with free space

Optionally

AFTER SUSPEND trigger

Abort

11 - 24

Copyright 2008, Oracle. All rights reserved.

/es,'i#g *,spe#ded *tate'e#ts +,ll (otes -age

11 - 25

Copyright 2008, Oracle. All rights reserved.

&ransporting &ablespaces

2 !esumable Allocation $ 9 &ransportable &'S &ransportable D'

/oncept: /ross,platform transportable tablespaces: Simplify data distribution between data warehouse and data marts Allow database migration from one platform to another Supported platforms:
*olaris?t'@ OA 932-$it: *olaris?t'@ OA 9!4-$it: 0icroso1t 2i#do&s 6A 932-$it: <i#,; 6A 932-$it: A67-8ased *yste's 9!4-$it: 4--.7 9!4-$it: 4- >r,!4 .(67 4--.7 6A 9!4-$it: <i#,; 6A 9!4-$it: 4- Ope# 50* 0icroso1t 2i#do&s 6A 9!4-$it: 680 =*eries 8ased <i#,; <i#,; !4-$it 1or A03 Apple 0ac O* 0icroso1t 2i#do&s !4-$it 1or A03 *olaris Operati#g *yste' 9;8!:
11 - 2! Copyright 2008, Oracle. All rights reserved.

/oncept: Minimum /ompatibility @evel


'oth source and target databases must have COMPATIBLE set to 102020 or higher$ Data file headers are platform,aware$ 'efore transporting, ma#e sure that all read,only and offline files are platform,aware$
!eadG write !ead, only COMPATIBLE=32420
11 - 2"

!eadG write !ead, only !eadG write !ead, only

COMPATIBLE=102020

Copyright 2008, Oracle. All rights reserved.

&ransportable &ablespace Procedure


Source Ma#e tablespaces read,only$ se Data Pump to e"tract metadata$ &arget uses the same endian formatJ Ies

Ao /onvert data files by using !MAA$

Ship data files and dump file to target$ se Data Pump to import metadata$ &arget
11 - 28

Ma#e tablespaces readGwrite$


Copyright 2008, Oracle. All rights reserved.

Determining the 0ndian )ormat of a Platform


SELECT 5p2e.67-._8o*m-5 FROM 9:5*-.spo*5-;le_pl-58o*m 5p< 9:6-5-;-se 6 WHERE 5p2pl-58o*m_.-me = 62pl-58o*m_.-me!

Source

&arget

11 - 2)

Copyright 2008, Oracle. All rights reserved.

&ransporting Databases

2 !esumable Allocation &ransportable &'S 9 &ransportable D'

Fenerali1e the transportable tablespace feature$ Data can easily be distributed from a data warehousing environment to data marts, which are usually on smaller platforms$ A database can be migrated from one platform to another very 4uic#ly$
Platform K Same -endianness. Platform I

Database files transfer 0"isting database


11 - 30

Aew database

Copyright 2008, Oracle. All rights reserved.

Database &ransportation Procedure: Source System /onversion

Open database in READ ONL( mode and COMPATIBLE=102020 !ead, only !ead, only Ship files !ead, only !ead, only

CON%ERT DATABASE TO PLATFORM

Source system

&arget system

11 - 31

Copyright 2008, Oracle. All rights reserved.

Database &ransportation Procedure: &arget System /onversion

Open database in READ ONL( mode and COMPATIBLE=102020 !ead, only Ship files !ead, only !ead, only !ead, only

CON%ERT DATABASE ON TAR'ET

Source system

&arget system

11 - 32

Copyright 2008, Oracle. All rights reserved.

Database &ransportation: /onsiderations


/reate the password file on the target platform$ &ransport the BFILEs used in the source database$ &he generated pfile and transport script use OM)$ se DBNEWID to change the DBID$

11 - 33

Copyright 2008, Oracle. All rights reserved.

Summary
(n this lesson, you should have learned how to: se the Oracle database to automatically manage space Proactively monitor and manage tablespace space usage se the Segment Advisor !eclaim wasted space from tables and inde"es by using the segment shrin# functionality Manage resumable space allocation Describe the concepts of transportable tablespaces and databases

11 - 34

Copyright 2008, Oracle. All rights reserved.

Practice Overview: Managing Storage


&his practice covers the following topics: sing threshold alerts to proactively manage tablespaces sing the Segment Advisor to shrin# space 5iewing alerts and alert history in SD@HPlus and 0nterprise Manager

11 - 35

Copyright 2008, Oracle. All rights reserved.

11 - 3!

Copyright 2008, Oracle. All rights reserved.

You might also like