Docsity

Understanding Data Storage and Memory Hierarchy: Disks and Their Access Methods, Slides of Database Management Systems (DBMS)

Partial preview of the text

Download Understanding Data Storage and Memory Hierarchy: Disks and Their Access Methods and more Slides Database Management Systems (DBMS) in PDF only on Docsity!

Data Storage

Memory Hierarchy

Disks

Strawman Implementation

  • Use UNIX file system to store relations, e.g.
    • Students(name, id, dept) in file /usr/db/Students
  • One line per tuple, each component stored as

character string, with # as a separator, e.g.

  • tuple could be: Smith#123#CS
  • Store schema in /usr/db/schema, e.g.:
  • Students#name#STR#id#INT#dept#STR

Strawman cont'd

  • To execute a query involving a join of two

relations R and S:

for each tuple (line) in R do for each tuple (line) in S do if the condition is satisfied then display the desired attributes

What's Wrong?

  • The storage of the tuples on disk is inflexible: if a student changes major from EE to ECON, entire file must be rewritten
  • Search is very expensive (read entire relation)
  • Query processing is "brute force" -- there are faster ways to do joins, etc.
  • Data is not buffered between disk and main memory
  • No concurrency control
  • No reliability in case of a crash

Memory Hierarchy

  • cache
  • main memory
  • secondary storage (disk)
  • tertiary storage (tapes, CD-ROM)

7

faster, smaller, more expensive

slower, larger, cheaper

Cache Memory

  • Transfer a few bytes at a time between cache

and main memory: instruction, integer,

floating point, short string

  • Processor operates on instruction and data in

the cache

  • Typical size: 1 Mbyte (2 20 bytes)
  • Typical speed to/from main memory: 100

nanosec (1 nanosec = 10 -9^ sec)

Secondary Storage

  • Usually disk
  • Divided logically into blocks, unit of transfer between main memory (called disk I/O )
  • Typical size: 100 Gbytes
  • Typical speed: 10 millisec (10-3^ sec)
  • At least 100 times larger than main memory
  • Much slower than main memory and much much slower than cache: can execute several million instructions during one disk I/O

Tertiary Storage

  • Tape(s)
  • CD-ROM(s)
  • At least 1000 times slower than secondary

storage

  • At least 1000 times larger than secondary

storage

Disks

13

disk heads^ spindle

platters: each has two surfaces, each surface consists of tracks (concentric rings)

one head per surface, very close to surface, does the reading and writing

More on Disks

14

orange ring is a track

black squares are gaps, which don't hold data

part of track between two gaps is a sector

one or more sectors make a block

Typical Values

  • Rotation speed: 5400 rmp
  • Number of platters: 5
  • Number of tracks/surface: 20,
  • Number of sectors/track: 500
  • Number of bytes/sector: thousands

Disk Latency for a Read

  • Time between issuing command to read a block and when contents of block appear in main memory: - time for processor and disk controller to process request, including resolving any contention (negligible) - seek time: time to move heads to correct radius (0 to 40 millisec) - rotational latency: time until first sector of block is under the head (5 millisec) - transfer time: until all sectors of the block have passed under the head; depends on rotation speed and size of block

Moral of the Story

  • Disks accesses are orders of magnitude slower

than accesses to main memory.

  • They are unavoidable in large databases.
  • Thus do everything possible to minimize

them.

  • Can lead to different algorithms than for main

memory model.

Speeding Up Disk Accesses

  1. Place blocks accessed together on same cylinder
    • reduces seek time and rotational latency
  2. Divide data among several disks
    • head assemblies can move in parallel
  3. Mirror a disk: make copies of it
    • speeds up reads: get data from disk whose head is closest to desired block
    • no effect on writes: write to all copies
    • also helps with fault tolerance