Download presentation
Presentation is loading. Please wait.
Published byBernard Caldwell Modified over 10 years ago
1
Primer on Structure& Storage Analysis Primer on Structure & Storage Analysis This presentation is supposed to give a simple and brief overview for storage calculations. THREE simple methods have been discussed for TABLE size calculation. ~ Nilendu Misra nilendu@innocent.com
2
Data Block 4 Data block is the smallest unit logical space allocation 4 Smallest unit of I/O 4 Data block size can ONLY be specified at creation time 4 Always multiple of OS block size 4 To see check DB_BLOCK_SIZE in init.ora
3
Oracle Block 4 Data Block = Header + “Actual” data 4 Header contains ‘information’ about the data 4 A row should ideally be contained within a single block Header Data Row Free Space
4
Extent & Segment 4 An extent is a specific number of contiguous data blocks 4 Several extents make one segment(e.G table, rollback segment) 4 All extents for the same segment are on the same tablespace 4 Rollback segment has ATLEAST 2 extents
5
Free Space Management : PCTFREE 4 Mention while creating or altering segment 4 FREELIST - list of blocks ready for insertion 4 % of the block kept free for updates of rows already in that block 4 PCTFREE = 10 (default) means the block (say 2K) allows row insertion till it is 80% full (1.8K). The rest (0.2K) is kept free
6
Pctused 4 When % of the block used falls below PCTUSED insertion is again allowed on the block 4 PCTUSED = 40 (default), in the previous example means when the block will contain 0.8K then again insertion will start
7
Why Consider these Parameters? 4 Disk I/O is the around 50 times slower than reading from memory (SGA) 4 We should prevent multiple I/Os while reading a record (e.g., Row Chaining) 4 This parameters put a big role in the total space consumed by the segment 4 Read-in blocks take up memory in SGA 4 Defining depends on the application (e.g., UPDATE intensive)
8
CONT. 4 e.g., In UPDATE intensive system PCTFREE should be high to accommodate the INCREASE in length due to UPDATE 4 In SELECT intensive system (say DSS) PCTFREE should be low. (As no UPDATE) 4 A Table can be INSERTed / DELETEd upon frequently. So HIGH PCTUSED is better 4 Row chaining –Row is ‘spread across’ more than one block
9
Designing Parameters 4 Knowledge of application data. 4 Knowledge of operations on individual Table (particularly Large ones) 4 Specifically the frequency of UPDATEs, INSERTs, DELETEs has to be known 4 A row with LONG datatype normally ‘spreads across’ multiple data blocks
10
Row Chaining 4 When a row is stored over multiple blocks 4 Because it does not get enough space on a single block to fit in 4 With large rows (with LONG,LONG RAW) 4 I/O is badly hit for scanning multiple blocks
11
EXTENT Calculation 4 MAXEXTENTS depend on data block size 4 For 2K block, MAXEXTENT = 121 4 When one extent is filled, NEXT extent is allocated 4 NEXT extent size = (current extent size) * (1 + PCTINCREASE/100) 4 PCTINCREASE = 0 =>same sized extents (as in rollback segment)
12
SEGMENT Types 4 DATA segment 4 INDEX segment 4 ROLLBACK segment 4 TEMP segment
13
Tablespace 4 Largest logical storage unit 4 Has one or more datafile(s) where data is actually stored 4 DBA can CREATE/ALTER/DROP 4 Associated with one or more user(s) 4 Each user MUST have one DEFAULT & one TEMPORARY tablespace
14
TABLESPACE (Cont.) 4 Size of a tablespace = sum of the datafiles 4 To increase ADD datafile 4 ONLY way to remove DATAFILE ----> DROP USER...; 4 Can take ONLINE/OFFLINE (except SYSTEM) 4 Create separate for each segment type
15
Datafile 4 One datafile is associated with ONE & ONLY ONE tablespace 4 SIZE can be ALTERED after creation 4 CANNOT be DROPPED on the fly 4 For big database AUTOEXTEND ON 4 MAX no/size of datafile is restricted by OS
16
Syntax : Create Tablespace CREATE TABLESPACE test DATAFILE ‘/data/oracle/test1.dbf’ SIZE 100M REUSE DEFAULT STORAGE (INITIAL 500K NEXT 1024K MINEXTENTS 2 MAXEXTENTS 50 PCTINCREASE 10) ;
17
Add Datafile ALTER TABLESPACE “RBS” ADD DATAFILE ‘/data/oracle/rbs4.dbf’ SIZE 100M;
18
Resize Datafile ALTER DATABASE DATAFILE ‘/oracle/datafile/test.dbf’ RESIZE 100m;
19
Autoextend Datafile Alter database datafile ‘/Data/oracle/test.dbf’ Autoextend on Next 100k ;
20
To See Size of Datafile Select file_name “name”, Sum(bytes)/1024/1024 “size” From sys.dba_data_files Group by file_name;
21
Tablespace Size Select sum(bytes)/1024/1024 “size”, Tablespace_name From sys.dba_data_files Group by tablespace_name;
22
Estimate Table Size - Method 1 Row/Data size from Table Structure(DDL) Table emp (name varchar2(30), salary number (8,2), join_date date); Step 1 : each row size ->20B + 6B + 7B = 43B Step 2 : estimated rows -> 10000 Step 3 : table size -> 43 * 10000B = 0.5 MB Step 4 : yearly growth rate -> 43 * 2000 = 100 KB Moral : Always be conservative Moral : Always be conservative
23
Estimate Table Size - Method 2 From Avg Row Size of existing Data Step 1 :Initial 40,Next 50,Extents 4,PctIncrease 50 Step 2 :Size : (90 + 50*1.5 + 50*1.5*1.5)= 287.5 Step 3 :Size with MaxExtents (121 for 2K DB Block) : It’s a G.P. Series. S = Sum of N terms = [A(R N -1)/(R-1)] where A = NEXT; R = (100+PctIncrease)/100; N= (MAXEXTENTS - 1) => Total Size = ( S + INITIAL) Moral : Set PctIncrease Judiciously! Moral : Set PctIncrease Judiciously!
24
Estimate Table Size - Method 3 Row/Data size from Analyzed table Info Step 1 :ANALYZE TABLE EMP ESTIMATE[COMPUTE] STATISTICS; Step 2 :SELECT (NUM_ROWS*AVG_ROW_LEN) FROM USER_TABLES WHERE TABLE_NAME = ‘EMP’;
25
To Check Extent Growth Select substr(owner || ‘.’|| segment_name,1,25) “object”, Maxextents From sys.Dba_extents Where maxextents -extents <= 5 Order by extents; 4 Will give you the segment which is approaching MAXEXTENTS
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.