Presentation is loading. Please wait.

Presentation is loading. Please wait.

9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.

Similar presentations


Presentation on theme: "9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating."— Presentation transcript:

1 9 Storage Structure and Relationships

2 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating the use of block space utilization parameters by objects Obtaining information about storage structures from the data dictionary Locating the segments by considering fragmentation and life-spans Listing the different segment types and their uses Controlling the use of extents by segments Stating the use of block space utilization parameters by objects Obtaining information about storage structures from the data dictionary Locating the segments by considering fragmentation and life-spans

3 9-3 Database LogicalPhysical Tablespace Data file O/S block Oracle block Segment Extent Database Storage Hierarchy

4 9-4 Types of Segments Table Cluster Table partition Index

5 9-5 Types of Segments Segments occupy space TableTable Table PartitionTable Partition table with high concurrent usage need partitioning option ClusterCluster based on key col values one or more tables in a cluster IndexIndex

6 9-6 Types of Segments Index-organized table Index partition Rollback segment Temporary segment

7 9-7 Types of Segments Index-organized tableIndex-organized table index+data stored together Index PartitionIndex Partition index can be partitioned Rollback segmentRollback segment before image of a data value Temporary segmentTemporary segment when sorts need more space

8 9-8 Types of Segments LOB index LOB segment Bootstrap segment Nested table

9 9-9 Storage Clause Precedence Oracle default (5 blocks) Tablespace Segment Controls how extents are allocated to segments Storage parameter at segment level overrides the one at TS level, etc.

10 9-10 Extent Allocation and Deallocation Allocated when the segment is + Created + Extended + Altered Deallocated when the segment is – Dropped – Altered – Truncated – Automatically resized (rollback segments only) Allocated when the segment is + Created + Extended + Altered Deallocated when the segment is – Dropped – Altered – Truncated – Automatically resized (rollback segments only)

11 9-11 Used and Free Extents *When tablespace is created, the data files contain the following elements: -A header block: the first block -One free extent consisting of the remaining part of the file *As segments are created, or extended, they are allocated space from the pool of free extents; as segments are released, truncated, released extents are added to the pool *Frequent allocation/deallocation leads to fragmentation

12 9-12 Used and Free Extents Data file Free extent Used extent File header SMON compacts free space; this is called coalescing

13 9-13 Coalescing Free Space Free extent Used extent File header Before ALTER TABLESPACE data01 COALESCE; After

14 9-14 Database Block: Review Minimum unit of I/O Consists of one or more O/S blocks Set by DB_BLOCK_SIZE Set at database creation and cannot be altered Minimum unit of I/O Consists of one or more O/S blocks Set by DB_BLOCK_SIZE Set at database creation and cannot be altered

15 9-15 Database Block Contents Header (contains row ptrs, trans info, Can grow as more rows are added) Free space (can get fragmented as Rows are inserted and Deleted; needs coalescing) Data

16 9-16 Table Row Contents Row header (locked or not, deleted or not, trans., etc.) Col 1 size, col1 data Col k size (null) Col l size (null) Define cols that can take null values last

17 9-17 Block Space Utilization Parameters (managing free space to account for updates to rows) INITRANS MAXTRANS (initial and max num of transactions that can concurrently make changes to the block at a point in time) PCTFREE (can insert rows until free space falls below this; default is 10) PCTUSED ( if free space falls below this, block goes on free List; default is 40) Blocks are on “free” list

18 9-18 Block Space Usage Inserts Inserts Inserts Inserts 12 34 PCTFREE=20PCTUSED=40 80% 80% 40%

19 9-19 Example Create table Employee (EID number not null, ENAME varchar2(50) Using INDEX Tablespace INDX Pctfree 10 Pctused 40 INITRANS 5 STORAGE (INITIAL … PCTINCREASE) ) PCTFREE 10 PCTUSED 60 INITRANS 5 STORAGE (INITIAL….) TABLESPACE DATA01; -- COLUMN placement can also be specified Create table Employee (EID number not null, ENAME varchar2(50) Using INDEX Tablespace INDX Pctfree 10 Pctused 40 INITRANS 5 STORAGE (INITIAL … PCTINCREASE) ) PCTFREE 10 PCTUSED 60 INITRANS 5 STORAGE (INITIAL….) TABLESPACE DATA01; -- COLUMN placement can also be specified

20 9-20 Segment Space Management in LMT From Oracle 9i, one can not only have bitmap managed tablespaces, but also bitmap managed segments when setting Segment Space Management to AUTO for a tablespace. Look at this example: SQL> CREATE TABLESPACE ts4 DATAFILE '/oradata/ts4_01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO; From Oracle 9i, one can not only have bitmap managed tablespaces, but also bitmap managed segments when setting Segment Space Management to AUTO for a tablespace. Look at this example: SQL> CREATE TABLESPACE ts4 DATAFILE '/oradata/ts4_01.dbf' SIZE 50M EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;

21 9-21 Segment Space Management in LMT Segment Space Management eliminates the need to specify and tune the PCTUSED, FREELISTS, and FREELISTS GROUPS storage parameters for schema objects. The Automatic Segment Space Management feature improves the performance of concurrent DML operations significantly since different parts of the bitmap can be used simultaneously eliminating serialization for free space lookups against the FREELSITS. This is of particular importance when using RAC.

22 9-22 Data Dictionary Views Tablespaces DBA_TABLESPACES Segments DBA_SEGMENTS Data files DBA_DATA_FILES Free extents DBA_FREE_SPACE Used extents DBA_EXTENTS

23 9-23 Querying Segment Information DBA_SEGMENTS – – General information – –OWNER SEGMENT_NAME – –SEGMENT_TYPE – –TABLESPACE_NAME DBA_SEGMENTS – – General information – –OWNER SEGMENT_NAME – –SEGMENT_TYPE – –TABLESPACE_NAME – – Size – – EXTENTS – – BLOCKS – – Storage settings – – INITIAL_EXTENT – – NEXT_EXTENT – – MIN_EXTENTS – – MAX_EXTENTS – – PCT_INCREASE

24 9-24 Example Select segment_name, tablespace_name, extents, blocks From dba_segments Where owner = ‘SCOTT’; Select segment_name, tablespace_name, extents, blocks From dba_segments Where owner = ‘SCOTT’;

25 9-25 Getting Used Extent Information DBA_EXTENTS – – Identification – –OWNER – –SEGMENT_NAME – –EXTENT_ID – – Location and size – –TABLESPACE_NAME – –RELATIVE_FNO – –FILE_ID – –BLOCK_ID – –BLOCKS DBA_EXTENTS – – Identification – –OWNER – –SEGMENT_NAME – –EXTENT_ID – – Location and size – –TABLESPACE_NAME – –RELATIVE_FNO – –FILE_ID – –BLOCK_ID – –BLOCKS

26 9-26 Example Select extent_id, file_id, block_id, blocks From dba_extents Where owner = ‘SCOTT’ AND segment_name = ‘EMP’; Select extent_id, file_id, block_id, blocks From dba_extents Where owner = ‘SCOTT’ AND segment_name = ‘EMP’;

27 9-27 Checking Free Extent Information DBA_FREE_SPACE – – Location and size – –TABLESPACE_NAME – –RELATIVE_FNO – –FILE_ID – –BLOCK_ID – –BLOCKS DBA_FREE_SPACE – – Location and size – –TABLESPACE_NAME – –RELATIVE_FNO – –FILE_ID – –BLOCK_ID – –BLOCKS

28 9-28 Example Select tablespace_name, count(*), max(blocks), sum(blocks) From dba_free_space Group by tablespace_name; Select tablespace_name, count(*), max(blocks), sum(blocks) From dba_free_space Group by tablespace_name;

29 9-29 Organizing Tablespaces Based on Fragmentation Propensity Tablespace SYSTEM TOOLS DATA n INDEX n RBS n TEMP n Fragmentation Zero Very low Low High Very high* Usage Data dictionary Applications Data segments Index segments Rollback segments Temporary segments * Relevant only if tablespace PERMANENT

30 9-30 Summary Allocation and deallocation of extents for different types of segments Block space utilization parameters Allocation and deallocation of extents for different types of segments Block space utilization parameters


Download ppt "9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating."

Similar presentations


Ads by Google