28
1 Physical Database Design 406706 Database Storage Structures Lecturer: Fadi Alhaddadin

1 DB Storage_structures(3)

Embed Size (px)

Citation preview

Page 1: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 1/28

1

Physical Database Design

406706

Database Storage Structures

Lecturer: Fadi Alhaddadin

Page 2: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 2/28

2

Learning Outcomes

• Database Architecture

• ole o! the Database Administrator

• "eneral Per!ormance #ssues

• $%amine Oracle&s StorageStructures

Page 3: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 3/28

Page 4: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 4/28

4

Administrator 's/

De'elo(er• *he DA is the sole authority !or

allocating system12ide resources

+dis3 s(ace usage auditing etc-• 5o2e'er there are many areas o!

o'erla( in res(onsibility bet2een

the DA and De'elo(ers

Page 5: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 5/28

5

Activity/User TypeDeveloper DBA

Database Design 

Data Structure Definition 

Recovery Policy 

Design and Implementation of Concurrency

Control Policies

 

Application Tuning 

nrolment of Users 

ho has Primary es(onsibility !oreach Acti'ity

Page 6: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 6/28

6

Database Architecture

QueryOptimiser 

Data Dictionary

Security Manager 

Concurrency Controller   Recovery Manager 

Page 7: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 7/28

7

#nteractions bet2een)om(onents

• Lets loo3 at a ty(ical scenario8/ ,uery is (arsed

9/ *able and column names sent by ,O to theDD

/ DD 'alidates names sends a message to theS;

4/ S; 'alidates access rights

</ DD no2 re(lies to ,O

6/ ,O generates a (lan !or e%ecution and sendsmessages to )) !or obtaining loc3s

7/ As transaction e%ecutes it 2rites in!ormationin the rollbac3 segments maintained by the

eco'ery ;anager

Page 8: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 8/28

Per!ormance #ssues

• *2o main !actors:8/ (rocessing time at the )P=

9/ Data retrie'al time at the dis3• Data retrie'al time >> Processing

time

• *hus ma?or ob?ecti'e is tominimise data retrie'al +#@O-costs

Page 9: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 9/28

!

Per!ormance #ssues 1

)om(ression• Data retrie'al costs minimised by

clustering  and@or compressing data

• )om(ression can be achie'ed byre(lacing large data !ields by a codingscheme that ta3es u( less s(ace

• *his 2ill ty(ically be used !or a table2ith large1sied te%t !ields

• *hese !ields can be re(laced by codes2hich re!erence the original te%t 'aluesin a loo3u( table

Page 10: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 10/28

1"

)lustering B Oracle&s

Solution• Oracle clusters data at the (hysical

le'el into data blocks

,- hat ha((ens 2hen data +table-sie > data bloc3 sie

A-

• *his is (recisely 2hat Oracle doesC

Page 11: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 11/28

11

Oracle&s StorageStructures1$%tents

• Oracle organises data bloc3s that areaccessed together into a singlecontiguous unit called an extent 

• *hus 2hen creating a table you s(eci!ythe sie o! the e%tent

• hen the table sie e%ceeds the sie o!the e%tent Oracle obtains another

e%tent• 5o2e'er there is no guarantee that the

ne%t e%tent is contiguous 2ith the(re'ious one

Page 12: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 12/28

12

$%tents

• Oracle allo2s the designer tos(eci!y the sie o! the !irst +initial-

and subseEuent +next - e%tents• For a table that 2ould be e%(ected

to gro2 linearly 2ith time the sie

o! the initial  and next  e%tents2ould be the same

Page 13: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 13/28

13

elationshi(s bet2een Data loc3s$%tents and Segments

Page 14: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 14/28

14

Oracle&s Storage Structures1Segments

• Segments are collections o! e%tentsthat belong to one logical unit B e/g/a table

• #n general there !our ty(es o!segments:

8/ *able

9/ #nde%/ ollbac3 +!or eco'ery-

4/ *em(orary +to store intermediateresults e/g/ during sorting-

Page 15: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 15/28

15

Oracle&s Storage Structures1

*ables(aces• *ables(ace: a database is di'ided into

logical storage units called tables(aces/

• $ach tables(ace in an OA)L$ databaseis com(rised o! one or more o(eratingsystem !iles called data !iles/

• A tables(aces data !iles (hysically storethe associated database data on dis3

Page 16: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 16/28

16

Database

Logical Physical  

Tablespace   Data file

OS block Oracle

 block 

Segment 

Extent 

Database Storage Hierarchy 

Page 17: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 17/28

17

*ables(aces and Data!iles

Page 18: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 18/28

11

Logical Structure Gersus

Physical Structure• Logical structures are com(osed o! orderly

grou(ings o! in!ormation that allo2 you to

mani(ulate and access related data/ *heycannot be 'ie2ed outside the database/

• Physical structures are com(osed o! o(erating

system com(onents and ha'e a (hysical nameand location/

Page 19: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 19/28

1!1!

Logical Structure

• *he logical structure o! an Oracledatabase include

BSchema ob?ects

BData bloc3s

B$%tents

BSegments and

B*ables(aces

Page 20: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 20/28

2"2"

Physical Database Structure

• $'ery database has one or more(hysical data!iles/ *he Physical

Structure o! an Oracle databaseinclude:

BData Files

Bedo log FilesB)ontrol Files

Page 21: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 21/28

2121

Physical Database Structure

• Data Files: the data!iles contain all thedatabase data and can be associated

2ith only one database/• edo Log !iles: (rimary !unction is to

record all changes made to data/ *hein!ormation in a redo log !ile is used

only to reco'er the database !rom asystem or media !ailure/

Page 22: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 22/28

2222

Physical Database Structure

• )ontrol File: contains entries thats(eci!y the (hysical structure o!

the database such as:BDatabase name

BHames and locations o! data!iles and

redo log !iles andB*ime stam( o! database creation/

Page 23: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 23/28

23

=sing *ables(aces

• Oracle uses a SIS*$; tables(aceto store internal in!ormation suchas the Data Dictionary

•=ser tables can also be stored inSIS*$; but this is notrecommended

• ;uti(le tables(aces ha'e thesead'antages: gi'es users better(er!ormance and !le%ibility

Page 24: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 24/28

24

Ad'antages o! ;ulti(le*ables(aces

8/ )ontrol o'er s(ace Euotas !or users

9/ etter control o'er data a'ailability byta3ing indi'idual tables(aces online or

o!!line/ Per!orm (artial database bac3u( or

reco'ery

4/ Parallelise ,ueries by (artitioning tables

and allocating them to se(aratetables(aces

</ educe contention bet2een ob?ects byallocating them to se(arate tables(aces

Page 25: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 25/28

25

)ontrolling Database Sie

• *ables(aces can be used tocontrol database sie in three

2ays:8/ Adding a ne2 tables(ace

9/ Adding a ne2 data!ile to an e%istingtables(ace

/ Allo2ing data!iles to gro2dynamically

• )hoice made by DA de(ending

on circumstances

Page 26: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 26/28

26

Oracle&s S(ace ;anagement

• Oracle maintains a list o! !ree

bloc3s !or each tables(ace• hen a ne2 e%tent +H bloc3s- is

reEuired Oracle uses the !ollo2ing

algorithm:1. Search for N+1 contiguous blocks (N, if N <5).

2. If an exact match is not foun then !racle searches for "

contiguous blocks, #here " $ N

If " < N+5, then %&& blocks are allocate to ne# extent

If " $ N+5, allocate N to ne# extent an return remainer to

free list

'. If neither 1 or 2 alies, !racle coalesces aacent blocks

(use) to release sace an obtain more free blocks

Page 27: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 27/28

27

e!erences

• )ha(ter on Physical DatabaseDesign in ;odern Database

;anagement by Je!!rey 5o!!er .othersK

• Oracle 88g Database )once(ts B

)ha(ters 8 9 . • Oracle 88g Administrator&s "uide

)ha(ter

Page 28: 1 DB Storage_structures(3)

7/24/2019 1 DB Storage_structures(3)

http://slidepdf.com/reader/full/1-db-storagestructures3 28/28

2

e'ie2 ,uestions

8/ List the main acti'ities in'ol'ed inPhysical Database Design

9/ Distinguish bet2een clustering and compression

/ 5o2 does Oracle ensure that data

in tables are clustered4/ #denti!y !our ad'antages o! using

tablespaces