Principles of Data Management. Lecture #2 (Storing Data: Disks and Files)

Similar documents
Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Database Management Systems need to:

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Storing Data: Disks and Files

Storing Data: Disks and Files. Storing and Retrieving Data. Why Not Store Everything in Main Memory? Chapter 7

Storing and Retrieving Data. Storing Data: Disks and Files. Solution 1: Techniques for making disks faster. Disks. Why Not Store Everything in Tapes?

Storing Data: Disks and Files

Storing Data: Disks and Files

Storing Data: Disks and Files

Storing Data: Disks and Files

L9: Storage Manager Physical Data Organization

Disks and Files. Jim Gray s Storage Latency Analogy: How Far Away is the Data? Components of a Disk. Disks

Database Systems. November 2, 2011 Lecture #7. topobo (mit)

Review 1-- Storing Data: Disks and Files

Disks and Files. Storage Structures Introduction Chapter 8 (3 rd edition) Why Not Store Everything in Main Memory?

Storing Data: Disks and Files. Administrivia (part 2 of 2) Review. Disks, Memory, and Files. Disks and Files. Lecture 3 (R&G Chapter 7)

Disks, Memories & Buffer Management

Storing Data: Disks and Files

Introduction to Data Management. Lecture #13 (Indexing)

Introduction to Data Management. Lecture 14 (Storage and Indexing)

CS122A: Introduction to Data Management. Lecture #14: Indexing. Instructor: Chen Li

STORING DATA: DISK AND FILES

Disks & Files. Yanlei Diao UMass Amherst. Slides Courtesy of R. Ramakrishnan and J. Gehrke

Normalization, Generated Keys, Disks

Storing Data: Disks and Files

Project is due on March 11, 2003 Final Examination March 18, pm to 10.30pm

Unit 2 Buffer Pool Management

Outlines. Chapter 2 Storage Structure. Structure of a DBMS (with some simplification) Structure of a DBMS (with some simplification)

Data Storage and Query Answering. Data Storage and Disk Structure (2)

Principles of Data Management. Lecture #3 (Managing Files of Records)

Database Management Systems. Buffer and File Management. Fall Queries. Query Optimization and Execution. Relational Operators

CS 405G: Introduction to Database Systems. Storage

Database Systems II. Secondary Storage

Unit 2 Buffer Pool Management

CPSC 421 Database Management Systems. Lecture 11: Storage and File Organization

Database Applications (15-415)

CSCI-GA Database Systems Lecture 8: Physical Schema: Storage

Goals for Today. CS 133: Databases. Relational Model. Multi-Relation Queries. Reason about the conceptual evaluation of an SQL query

ECS 165B: Database System Implementa6on Lecture 3

Database design and implementation CMPSCI 645. Lecture 08: Storage and Indexing

Today: Secondary Storage! Typical Disk Parameters!

Database Architecture 2 & Storage. Instructor: Matei Zaharia cs245.stanford.edu

Roadmap. Handling large amount of data efficiently. Stable storage. Parallel dataflow. External memory algorithms and data structures

A memory is what is left when something happens and does not completely unhappen.

CMSC 424 Database design Lecture 12 Storage. Mihai Pop

BBM371- Data Management. Lecture 2: Storage Devices

I/O CANNOT BE IGNORED

Advanced Database Systems

Virtual Memory. Reading. Sections 5.4, 5.5, 5.6, 5.8, 5.10 (2) Lecture notes from MKP and S. Yalamanchili

User Perspective. Module III: System Perspective. Module III: Topics Covered. Module III Overview of Storage Structures, QP, and TM

Introduction to Database Systems CSE 444. Transactions. Lecture 14: Transactions in SQL. Why Do We Need Transactions. Dirty Reads.

Managing Storage: Above the Hardware

Storage Devices for Database Systems

Why Is This Important? Overview of Storage and Indexing. Components of a Disk. Data on External Storage. Accessing a Disk Page. Records on a Disk Page

CSE 451: Operating Systems Spring Module 12 Secondary Storage

Database Applications (15-415)

Physical Data Organization. Introduction to Databases CompSci 316 Fall 2018

Storage. CS 3410 Computer System Organization & Programming

Introduction Disks RAID Tertiary storage. Mass Storage. CMSC 420, York College. November 21, 2006

Storage and File Structure. Classification of Physical Storage Media. Physical Storage Media. Physical Storage Media

Storage and File Structure

Ch 11: Storage and File Structure

CS 554: Advanced Database System

Lecture 14: Transactions in SQL. Friday, April 27, 2007

Professor: Pete Keleher! Closures, candidate keys, canonical covers etc! Armstrong axioms!

CSE 190D Database System Implementation

COMP283-Lecture 3 Applied Database Management

Mass-Storage Structure

Chapter 10 Storage and File Structure

I/O CANNOT BE IGNORED

Introduction to I/O and Disk Management

CS3600 SYSTEMS AND NETWORKS

Introduction to I/O and Disk Management

CS143: Disks and Files

Adapted from instructor s supplementary material from Computer. Patterson & Hennessy, 2008, MK]

Chapter 10: Mass-Storage Systems

Parser. Select R.text from Report R, Weather W where W.image.rain() and W.city = R.city and W.date = R.date and R.text.

Monday, May 4, Discs RAID: Introduction Error detection and correction Error detection: Simple parity Error correction: Hamming Codes

Computer System Architecture

COS 318: Operating Systems. Storage Devices. Vivek Pai Computer Science Department Princeton University

V. Mass Storage Systems

DATA STORAGE, RECORD and FILE STUCTURES

Storage System COSC UCB

CSE 232A Graduate Database Systems

Mass-Storage. ICS332 - Fall 2017 Operating Systems. Henri Casanova

Chapter 10: Mass-Storage Systems

Classifying Physical Storage Media. Chapter 11: Storage and File Structure. Storage Hierarchy (Cont.) Storage Hierarchy. Magnetic Hard Disk Mechanism

Classifying Physical Storage Media. Chapter 11: Storage and File Structure. Storage Hierarchy. Storage Hierarchy (Cont.) Speed

COS 318: Operating Systems. Storage Devices. Jaswinder Pal Singh Computer Science Department Princeton University

CS 201 The Memory Hierarchy. Gerson Robboy Portland State University

CS 261 Fall Mike Lam, Professor. Memory

Disk Scheduling. Based on the slides supporting the text

Components of the Virtual Memory System

ECS 165B: Database System Implementa6on Lecture 2

Data Storage - I: Memory Hierarchies & Disks. Contains slides from: Naci Akkök, Pål Halvorsen, Hector Garcia-Molina, Ketil Lund, Vera Goebel

Chapter 12: Mass-Storage

Chapter 9: Peripheral Devices: Magnetic Disks

COS 318: Operating Systems. Storage Devices. Kai Li Computer Science Department Princeton University

Chapter 10: Mass-Storage Systems. Operating System Concepts 9 th Edition

ECE331: Hardware Organization and Design

Chapter 14: Mass-Storage Systems

Transcription:

Principles of Data Management Lecture #2 (Storing Data: Disks and Files) Instructor: Mike Carey mjcarey@ics.uci.edu Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1 Today s Topics v Today is the real start of this course! v Remember to read the course wiki page http://www.ics.uci.edu/~cs222 http://www.ics.uci.edu/~cs122c v Also follow the Piazza page https://piazza.com/uci/fall2014/cs122ccs222/ home There have already been lots of good questions and answers appearing there... Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 2

Disks and Files v DBMS stores information on ( hard ) disks. v This has major implications for DBMS design! READ: transfer data from disk to main memory (RAM). WRITE: transfer data from RAM to disk. Both are high-cost operations, relative to in-memory operations, so must be planned carefully! Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 3 Why Not Store Everything in Main Memory? v Costs too much. Dell wants (in early 2014) $65 for 500GB of disk, $600 for 256GB of SSD, and $57 for 4GB of RAM ($0.13, $2.34, $14.25 per GB) v Main memory is volatile. We want data to be saved between runs. (Obviously!) v Your typical (basic) storage hierarchy: Main memory (RAM) for currently used data Disk for the main database (secondary storage) Tapes for archiving older versions of the data (tertiary storage) v And we also have L1 & L2 caches, SSD, Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 4

Storage Hierarchy & Latency (Jim Gray): How Far Away is the Data? 10 9 Tape /Optical Robot Andromeda 2,000 years 10 6 Disk Pluto 2 years 100 Memory 1.5 hr 10 2 1 On Board Cache On Chip Cache Registers This Room My Head 10 min 1 min Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 5 Disks v Secondary storage device of choice. v Main advantage over tapes: random access vs. sequential. v Data is stored and retrieved in units called disk blocks or pages. v Unlike RAM, time to retrieve a disk page varies depending upon location on disk. Therefore, relative placement of pages on disk has a major impact on DBMS performance! (SSDs simplify things a bit in this respect) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 6

Components of a Disk v The platters spin (5400 rpm) v The arm assembly is moved in or out to position a head on a desired track Tracks under heads form a cylinder (imaginary!) v Only one head reads/writes at any one time. v Block size is a multiple of sector size (which is fixed) Arm assembly Disk head Arm movement Spindle Tracks Sector Platters Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 7 Accessing a Disk Page v Time to access (read/write) a disk block: seek time (moving arms to position disk head on track) rotational delay (waiting for block to rotate under head) transfer time (actually moving data to/from disk surface) v Seek time and rotational delay dominate. Seek time varies from about 1 to 20msec Rotational delay varies from 0 to 10msec Transfer rate is about 1 msec per 4KB page (old) v Key to lower I/O cost: Reduce seek/rotation delays! Hardware vs. software solutions? Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 8

Arranging Pages on Disk v `Next block concept: blocks on same track, followed by blocks on same cylinder, followed by blocks on adjacent cylinder v Blocks in a file should be arranged sequentially on disk (by `next ) in order to minimize seek and rotational delay v For a sequential scan, prefetching several pages at a time is a big win! Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 9 RAID (Redundant Array of Inexpensive Disks) v Disk Array: Arrangement of several disks that gives abstraction of a single, large disk. v Goals: Increase performance and reliability. v Two main techniques: Data striping: Data is partitioned; size of a partition is called the striping unit. Partitions are distributed over several disks. Redundancy: More disks => more failures. Redundant information allows reconstruction of data if a disk fails. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 10

RAID Levels v Level 0: No redundancy (just striping) v Level 1: Mirrored (two identical copies) Each disk has an exact mirror image Parallel reads; writes involve two disks Maximum transfer rate = transfer rate of one disk v Level 0+1: Striping and Mirroring Parallel reads; writes involves two disks Maximum transfer rate = aggregate bandwidth Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 11 RAID Levels (Contd.) v Level 3: Bit-Interleaved Parity Striping Unit: One bit. (One check disk.) Each read and write request involves all disks; disk array can process one request at a time. v Level 4: Block-Interleaved Parity Striping Unit: One disk block. (One check disk.) Parallel reads possible for small requests, large requests can utilize full bandwidth Writes involve modified block and check disk v Level 5: Block-Interleaved Distributed Parity Similar to RAID Level 4, but parity blocks are distributed over all disks Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 12

RAID Levels (Contd.) (Source: http://www.seagate.com/manuals/network-storage/business-storage-nas-os/raid-modes/) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 13 Disk Space Management v Lowest layer of DBMS software manages the space on disk. v Higher levels call upon this layer to: allocate/de-allocate a page read/write a page v A request for a sequence of pages must be satisfied by allocating the pages sequentially on disk! Higher levels don t need to know how this is done or how free space is managed. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 14

Buffer Management in a DBMS Page Requests from Higher Levels BUFFER POOL disk page free frame MAIN MEMORY DISK DB choice of frame dictated by replacement policy v Data must be in RAM for DBMS to operate on it! v Table of <frame#, pageid> pairs is maintained. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 15 When a Page is Requested... v If requested page is not in pool: Choose a frame for replacement If that frame is dirty, write it to disk Read requested page into chosen frame v Pin the page and return its address If requests can be predicted (e.g., sequential scans) pages can be prefetched several pages at a time! Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 16

More on Buffer Management v Requestor of page must unpin it, and indicate whether page has been modified, when done: dirty bit used for the latter purpose v Page in pool may be requested many times a pin count is used, and a page is a candidate for replacement iff pin count = 0. v CC & recovery may entail additional I/O when a frame is chosen for replacement. (Write-Ahead Log protocol; more in CS 223.) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 17 Buffer Replacement Policy v Frame is chosen for replacement using a replacement policy: Least-recently-used (LRU), Clock, MRU, etc. v Policy can have big impact on # of I/O s; depends on the access pattern. v Sequential flooding: Nasty situation caused by LRU + (repeated) sequential scans. # buffer frames < # pages in file means each page request causes an I/O. MRU much better in this situation (but not in all situations, of course). Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 18

DBMS vs. OS File System OS does disk space & buffer management so why not let the OS manage these tasks? v Differences in OS support: portability issues v Some limitations, e.g., files can t span disks. v Buffer management in DBMS requires ability to: pin a page in buffer pool, force a page to disk (important for implementing CC & recovery), and adjust replacement policy, and prefetch pages based on access patterns in typical DB operations. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 19 Next Time v We ll talk about files of records and associated approaches to Space management Record formats File formats v You should read ahead after we ve covered this stuff you will know everything needed for Project 1 (and you already know most of it ) and you should have gotten started on Project 1 already (and many of you clearly have) Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 20