Docsity

Hardware-Database System Principles-Lecture Slides, Slides of Principles of Database Management

Toggle sidebar
bg1
1
CS 245 Notes 2 1
CS 245: Database System
Principles
Notes 02: Hardware
Hector Garcia-Molina
CS 245 Notes 2 2
Outline
• Hardware: Disks
• Access Times
• Example - Megatron 747
• Optimizations
•Other Topics:
–Storage costs
– Using secondary storage
–Disk failures
CS 245 Notes 2 3
Hardware
DBMS
Data Storage
CS 245 Notes 2 4
P
M C
Typical
Computer
Secondary
Storage
...
...
CS 245 Notes 2 5
Processor
Fast, slow, reduced instruction set,
with cache, pipelined…
Speed: 100 500 1000 MIPS
Memory
Fast, slow, non-volatile, read-only,…
Access time: 10-6 10-9 sec.
1 s 1 ns
CS 245 Notes 2 6
Secondary storage
Many flavors:
- Disk: Floppy (hard, soft)
Removable Packs
Winchester
Ram disks
Optical, CD-ROM…
Arrays
- Tape Reel, cartridge
Robots
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Hardware-Database System Principles-Lecture Slides and more Slides Principles of Database Management in PDF only on Docsity!

CS 245 Notes 2 1

CS 245: Database System Principles

Notes 02: Hardware

Hector Garcia-Molina

CS 245 Notes 2 2

Outline

  • Hardware: Disks
  • Access Times
  • Example - Megatron 747
  • Optimizations
  • Other Topics:
    • Storage costs
    • Using secondary storage
    • Disk failures

CS 245 Notes 2 3

Hardware

DBMS

Data Storage

CS 245 Notes 2 4

P

M C

Typical Computer

Secondary Storage

CS 245 Notes 2 5

Processor Fast, slow, reduced instruction set, with cache, pipelined… Speed: 100  500  1000 MIPS

Memory Fast, slow, non-volatile, read-only,… Access time: 10 -6^  10 -9^ sec. 1 s  1 ns

CS 245 Notes 2 6

Secondary storage

Many flavors:

  • Disk: Floppy (hard, soft)

Removable Packs

Winchester

Ram disks

Optical, CD-ROM…

Arrays

  • Tape Reel, cartridge

Robots

CS 245 Notes 2 7

Focus on: “Typical Disk”

Terms: Platter, Head, Actuator

Cylinder, Track

Sector (physical),

Block (logical), Gap

CS 245 Notes 2 8

Top View

CS 245 Notes 2 9

“Typical” Numbers

Diameter: 1 inch  15 inches

Cylinders: 100  2000

Surfaces: 1 (CDs) 

(Tracks/cyl) 2 (floppies)  30

Sector Size: 512B  50K

Capacity: 360 KB (old floppy)

 400 GB (I use)

CS 245 Notes 2 10

Disk Access Time

block x

in memory

?

I want

block X

CS 245 Notes 2 11

Time = Seek Time +

Rotational Delay +

Transfer Time +

Other

CS 245 Notes 2 12

Seek Time

3 or 5x

x 1 N Cylinders Traveled

Time

CS 245 Notes 2 19

Other Delays

  • CPU time to issue I/O
  • Contention for controller
  • Contention for bus, memory

“Typical” Value: 0

CS 245 Notes 2 20

  • So far: Random Block Access
  • What about: Reading “Next” block?

CS 245 Notes 2 21

If we do things right (e.g., Double Buffer,

Stagger Blocks…) Time to get = Block Size + Negligible block t

  • skip gap
  • switch track
  • once in a while, next cylinder

CS 245 Notes 2 22

Rule of Random I/O: Expensive

Thumb Sequential I/O: Much less

  • Ex: 1 KB Block » Random I/O:  20 ms. » Sequential I/O:  1 ms.

CS 245 Notes 2 23

Cost for Writing similar to Reading

…. unless we want to verify!

need to add (full) rotation + Block size

t

CS 245 Notes 2 24

  • To Modify a Block?

CS 245 Notes 2 25

  • To Modify a Block?

To Modify Block:

(a) Read Block (b) Modify in Memory (c) Write Block [(d) Verify?]

CS 245 Notes 2 26

Block Address:

  • Physical Device
  • Cylinder #
  • Surface #
  • Sector

CS 245 Notes 2 27

Complication: Bad Blocks

  • Messy to handle
  • May map via software to

integer sequence

. Map Actual Block Addresses

m

CS 245 Notes 2 28

  • 3.5 in diameter
  • 3600 RPM
  • 1 surface
  • 16 MB usable capacity (16 X 2^20 )
  • 128 cylinders
  • seek time: average = 25 ms. adjacent cyl = 5 ms.

An Example Megatron 747 Disk (old)

CS 245 Notes 2 29

  • 1 KB blocks = sectors
  • 10% overhead between blocks
  • capacity = 16 MB = (2^20 )16 = 2 24
  • cylinders = 128 = 2^7

  • bytes/cyl = 2 24 /2 7 = 2 17 = 128 KB
  • blocks/cyl = 128 KB / 1 KB = 128

CS 245 Notes 2 30

3600 RPM 60 revolutions / sec 1 rev. = 16.66 msec. One track:

CS 245 Notes 2 37

The NEW Megatron 747 (Example 2.1 book)

  • 8 Surfaces, 3.5 Inch diameter
    • outer 1 inch used
  • 2 13 = 8192 Tracks/surface
  • 256 Sectors/track
  • 2 9 = 512 Bytes/sector

CS 245 Notes 2 38

  • 8 GB Disk
  • If all tracks have 256 sectors
    • Outermost density: 100,000 bits/inch
    • Inner density: 250,000 bits/inch

1

CS 245 Notes 2 39

  • Outer third of tracks: 320 sectors
  • Middle third of tracks: 256
  • Inner third of tracks: 192
  • Density: 114,000  182,000 bits/inch

CS 245 Notes 2 40

Timing for new Megatron 747 (Ex 2.3)

  • Time to read 4096-byte block:
    • MIN: 0.5 ms
    • MAX: 33.5 ms
    • AVE: 14.8 ms

CS 245 Notes 2 41

Outline

  • Hardware: Disks
  • Access Times
  • Example: Megatron 747
  • Optimizations
  • Other Topics
    • Storage Costs
    • Using Secondary Storage
    • Disk Failures

here

CS 245 Notes 2 42

Optimizations (in controller or O.S.)

  • Disk Scheduling Algorithms
    • e.g., elevator algorithm
  • Track (or larger) Buffer
  • Pre-fetch
  • Arrays
  • Mirrored Disks
  • On Disk Cache

CS 245 Notes 2 43

Double Buffering

Problem: Have a File » Sequence of Blocks B1, B Have a Program » Process B » Process B » Process B

CS 245 Notes 2 44

Single Buffer Solution

(1) Read B1  Buffer (2) Process Data in Buffer (3) Read B2  Buffer (4) Process Data in Buffer ...

CS 245 Notes 2 45

Say P = time to process/block R = time to read in 1 block n = # blocks

Single buffer time = n(P+R)

CS 245 Notes 2 46

Double Buffering

Memory:

Disk: A B C D E F G

process

CS 245 Notes 2 47

Double Buffering

Memory:

Disk: A B C D E F G

B

done

process

A

CS 245 Notes 2 48

Double Buffering

Memory:

Disk: A B C D E F G

AC

process

B

done

CS 245 Notes 2 55

Trend

  • As memory prices drop, blocks get bigger ...

Trend

CS 245 Notes 2 56

Storage Cost

10 -9^10 -6^10 -3^10 -0^10 access time (sec)

10 15 10 13 10 11 10 9 10 7 10 5 10 3

cache

electronic main

electronic secondary

magneticoptical disks online tape

nearline opticaltape & disks

offlinetape

typical capacity (bytes)

from Gray & Reuter

CS 245 Notes 2 57

Storage Cost

10 -9^10 -6^10 -3^10 -0^10 access time (sec)

10 4 10 2

10 0

10 - 10 -

cache electronic main electronic secondary magneticoptical disks

onlinetape nearline tape &optical disks offline tape

dollars/MB

from Gray & Reuter

CS 245 Notes 2 58

Using secondary storage effectively

(Sec. 2.3)

  • Example: Sorting data on disk
  • Conclusion:
    • I/O costs dominate
    • Design algorithms to reduce I/O
  • Also: How big should blocks be?

CS 245 Notes 2 59

Five Minute Rule

  • THE 5 MINUTE RULE FOR TRADING MEMORY FOR DISC ACCESSES Jim Gray & Franco Putzolu May 1985
  • The Five Minute Rule, Ten Years Later Goetz Graefe & Jim Gray December 1997 CS 245 Notes 2 60

Five Minute Rule

  • Say a page is accessed every X seconds
  • CD = cost if we keep that page on disk
    • $D = cost of disk unit
    • I = numbers IOs that unit can perform
    • In X seconds, unit can do XI IOs
    • So CD = $D / XI

CS 245 Notes 2 61

Five Minute Rule

  • Say a page is accessed every X seconds
  • CM = cost if we keep that page on RAM
    • $M = cost of 1 MB of RAM
    • P = numbers of pages in 1 MB RAM
    • So CM = $M / P

CS 245 Notes 2 62

Five Minute Rule

  • Say a page is accessed every X seconds
  • If CD is smaller than CM,
    • keep page on disk
    • else keep in memory
  • Break even point when CD = CM, or $D P

X = I $M

CS 245 Notes 2 63

Using ‘97 Numbers

  • P = 128 pages/MB (8KB pages)
  • I = 64 accesses/sec/disk
  • $D = 2000 dollars/disk (9GB + controller)
  • $M = 15 dollars/MB of DRAM
  • X = 266 seconds (about 5 minutes) (did not change much from 85 to 97)

CS 245 Notes 2 64

Disk Failures (Sec 2.5)

  • Partial  Total
  • Intermittent  Permanent

CS 245 Notes 2 65

Coping with Disk Failures

  • Detection
    • e.g. Checksum
  • Correction  Redundancy

CS 245 Notes 2 66

At what level do we cope?

  • Single Disk
    • e.g., Error Correcting Codes
  • Disk Array

Logical (^) Physical