1 / 31

Chapter 11: Storage and File Structure

Chapter 11: Storage and File Structure. Hankz Hankui Zhuo. What factors we care about. Speed Cost Reliability data loss: power failure, or system crash physical failure. Classification of Physical Storage Media. volatile storage loses contents when power is switched off

amara
Download Presentation

Chapter 11: Storage and File Structure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 11: Storage and File Structure HankzHankuiZhuo

  2. What factors we care about • Speed • Cost • Reliability • data loss: power failure, or system crash • physical failure

  3. Classification of Physical Storage Media • volatile storage • loses contents when power is switched off • non-volatile storage • Contents persist even when power is switched off

  4. Physical Storage Media • Cache • Fastest • Most costly • Volatile • Main memory • Fast • Too small/expensive to store entire DB • Volatile

  5. Physical Storage Media • Flash memory • Non-volatile • Reads roughly as fast as main memory • Writes/erases are slow • Cost similar to main memory • Widely used in embedded devices, e.g., digital cameras

  6. Physical Storage Media • Magnetic-disk • Stored on spinning disk • Primary medium for DB • Slower than main memory • Non-volatile • Large capacity

  7. Physical Storage Media • Optical storage • non-volatile • Read from a spinning disk using a laser • Examples: DVD, CD-ROM • Slower than magnetic disk

  8. Physical Storage Media • Tape storage • Non-volatile • Sequential-access • Much slower than disk • Storage costs much cheaper than disk, but drives are expensive

  9. Storage Hierarchy

  10. Storage Hierarchy Primary storage Secondary storage Tertiary storage

  11. Magnetic Hard Disk Mechanism

  12. Performance Measures of Disks • Access time • Seek time • time it takes to reposition the arm over the correct track. • Rotational latency • time it takes for the sector to be accessed to appear under the head. • Data-transfer rate • ?MB per second

  13. Performance Measures of Disks • Mean time to failure (MTTF) • the average time the disk is expected to run continuously without any failure. • Typically 3 to 5 years • MTTF decreases as disk ages

  14. Optimization of Disk-Block Access • Block – a contiguous sequence of sectors from a single track • data is transferred in blocks • sizes range from 512 bytes to several kilobytes • Smaller blocks: more transfers from disk • Larger blocks: more space wasted due to partially filled blocks • Typical block sizes today range from 4 to 16 kilobytes

  15. Optimization of Disk-Block Access • Disk-arm-scheduling • order pending accesses to tracks, so that disk arm movement is minimized • Elevator algorithm • Move in one direction • Process requests in that direction till no more requests in that direction • Then reverse direction and repeat

  16. RAID: Redundant Arrays of Independent Disks • Easy to fail when using lots of disks • Cause data loss • Using redundancy • To avoid data loss

  17. Improvement of Reliability via Redundancy • Redundancy • Store extra information: used to rebuild information lost in a disk failure • E.g., mirroring • Duplicate every disk • Write on both disks • Read from either disk • If a disk fails, data is still available in the other • Mean time to data loss depends on: • Mean time to failure, and • Mean time to repair

  18. Buffer Manager

  19. Buffer Manager • Programs call on the buffer manager when they need a block from disk. • If the block is already in the buffer, buffer manager returns the address of the block in main memory

  20. Buffer Manager 2. If the block is not in the buffer, the buffer manager allocates space in the buffer for the block A. Replacing (throwing out) some other block, if required, to make space for the new block. B. Replaced block written back to disk only if it was modified since the most recent time that it was written to/fetched from the disk.

  21. Buffer-Replacement Policies • Most operating systems replace the block least recently used (LRU strategy) • You can design many policies to replace blocks • To minimize time cost of transferring data • E.g., statistical methods?

  22. File Organization

  23. File Organization • Database is stored as • A collection of files • A file is a sequence of records • A record is a sequence of attributes

  24. Fixed-Length Records • Simple approach: • Store record i starting from byte n  (i – 1), where n is the size of each record. • Record access is simple but records may cross blocks • Deletion of record i: • move records i + 1, . . ., m to i, . . . , m – 1, or • move record m to i • link all free records on a free list

  25. Free Lists

  26. Variable-Length Records • More complicated than fixed-length records • Please refer to the text book

  27. Organization of Records in Files • Heap– a record can be placed anywhere in the file where there is space • Sequential – store records in sequential order, based on the value of the search key of each record • Hashing – a hash function computed on some attribute of each record; the result specifies in which block of the file the record should be placed

  28. Sequential File Organization • Suitable for applications that require sequential processing of the entire file • The records in the file are ordered by a search-key

  29. Sequential File Organization • Deletion – use pointer chains • Insertion –locate the position where the record is to be inserted • if there is free space insert there • if no free space, insert the record in an overflow block • In either case, pointer chain must be updated

  30. Sequential File Organization • For example: • Need to reorganize the file from time to time to restore sequential order

  31. The end

More Related