Storing Data: Disks and Files

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

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

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

Storing Data: Disks and Files

Storing Data: Disks and Files

Storing Data: Disks and Files

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

Storing Data: Disks and Files

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 and Retrieving Data. Why Not Store Everything in Main Memory? Chapter 7

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

L9: Storage Manager Physical Data Organization

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

Review 1-- Storing Data: Disks and Files

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

Disks, Memories & Buffer Management

STORING DATA: DISK AND FILES

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

CS 405G: Introduction to Database Systems. Storage

Introduction to Data Management. Lecture #13 (Indexing)

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

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

Unit 2 Buffer Pool Management

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

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

Storing Data: Disks and Files

Unit 2 Buffer Pool Management

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

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

Database Applications (15-415)

Normalization, Generated Keys, Disks

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

Database Systems II. Secondary Storage

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

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

ECS 165B: Database System Implementa6on Lecture 3

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

CSE 451: Operating Systems Winter Secondary Storage. Steve Gribble. Secondary storage

CSE 451: Operating Systems Spring Module 12 Secondary Storage

CSE 190D Database System Implementation

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

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

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.

Physical Data Organization. Introduction to Databases CompSci 316 Fall 2018

CMSC 424 Database design Lecture 12 Storage. Mihai Pop

Managing Storage: Above the Hardware

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

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

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

CSE 451: Operating Systems Spring Module 12 Secondary Storage. Steve Gribble

Database Applications (15-415)

Today: Secondary Storage! Typical Disk Parameters!

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

Storage Devices for Database Systems

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

CSE 153 Design of Operating Systems Fall 2018

CSE 232A Graduate Database Systems

The Memory Hierarchy 10/25/16

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

Advanced Database Systems

CSE 451: Operating Systems Winter Lecture 12 Secondary Storage. Steve Gribble 323B Sieg Hall.

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

CS 201 The Memory Hierarchy. Gerson Robboy Portland State University

DATA STORAGE, RECORD and FILE STUCTURES

Overview of Storage & Indexing (i)

Secondary storage. CS 537 Lecture 11 Secondary Storage. Disk trends. Another trip down memory lane

UNIT 2 Data Center Environment

ECE331: Hardware Organization and Design

BBM371- Data Management. Lecture 2: Storage Devices

ECS 165B: Database System Implementa6on Lecture 2

CSCI-UA.0201 Computer Systems Organization Memory Hierarchy

CS 31: Intro to Systems Storage and Memory. Kevin Webb Swarthmore College March 17, 2015

File Structures and Indexing

Page 1. Goals for Today" TLB organization" CS162 Operating Systems and Systems Programming Lecture 11. Page Allocation and Replacement"

Advanced Database Systems

Module 1: Basics and Background Lecture 4: Memory and Disk Accesses. The Lecture Contains: Memory organisation. Memory hierarchy. Disks.

6.033 Computer System Engineering

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

CSE 153 Design of Operating Systems

Ref: Chap 12. Secondary Storage and I/O Systems. Applied Operating System Concepts 12.1

Disks October 22 nd, 2010

Lecture 12. Lecture 12: The IO Model & External Sorting

Mass-Storage Structure

CS370 Operating Systems

Instructor: Amol Deshpande

CS 261 Fall Mike Lam, Professor. Memory

Hard Disk Drives. Nima Honarmand (Based on slides by Prof. Andrea Arpaci-Dusseau)

Disks March 15, 2010

1.1 Bits and Bit Patterns. Boolean Operations. Figure 2.1 CPU and main memory connected via a bus. CS11102 Introduction to Computer Science

Important Note. Today: Starting at the Bottom. DBMS Architecture. General HeapFile Operations. HeapFile In SimpleDB. CSE 444: Database Internals

What we already know. Late Days. CSE 444: Database Internals. Lecture 3 DBMS Architecture

Chapter 10: Mass-Storage Systems

Page Replacement. (and other virtual memory policies) Kevin Webb Swarthmore College March 27, 2018

CS162 Operating Systems and Systems Programming Lecture 11 Page Allocation and Replacement"

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2017 Lecture 13

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

RAID in Practice, Overview of Indexing

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

Transcription:

Storing Data: Disks and Files CS 186 Fall 2002, Lecture 15 (R&G Chapter 7) Yea, from the table of my memory I ll wipe away all trivial fond records. -- Shakespeare, Hamlet Stuff Rest of this week My office hours cancelled this Thursday (10/17) Send mail if this is a problem Sirish Chandrasekaran will cover class on Tuesday Project Phase 2 Due Wednesday at 5pm Example testing script posted --- make sure it works! Project Phase 3 Extended Data Types Out next wee Midterm See next slide 1

Review and Context First half of course how to use a database Aren t Databases Great? Data Modeling with ER Relational Model and Query Languages Rest of the course A peek under the hood. Where are the bits? How to find them and keep track of them? How to process those pesky SQL queries How to ensure Transactional Semantics The BIG Picture Queries Query Optimization and Execution Relational Operators Files and Access Methods Buffer Management Disk Space Management DB 2

Disks and Files DBMS stores information on disks. In an electronic world, disks are a mechanical anachronism! 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! Why Not Store It All in Main Memory? Costs too much. $100 will buy you either 0.5 GB of RAM or 100 GB of disk (EIDI/ATA) or 20GB (SCSI) or today. High-end Databases today in the 10-100 TB range. Approx 60% of the cost of a production system is in the disks. Main memory is volatile. We want data to be saved between runs. (Obviously!) Note, some specialized systems do store entire database in main memory. Vendors claim 10x speed up vs. traditional DBMS running in main memory. 3

The Storage Hierarchy Smaller, Faster Main memory (RAM) for currently used data. Disk for the main database (secondary storage). Tapes for archiving older versions of the data (tertiary storage). QUESTION: Why does it have to be a hierarchy? Source: Operating Systems Concepts 5th Edition Bigger, Slower Jim Gray s Storage Latency Analogy: How Far Away is the Data? 10 9 Andromeda Tape /Optical Robot 2,000 Years 10 6 Disk Pluto 2 Years 100 Memory Sacramento 1.5 hr 10 2 1 On Board Cache On Chip Cache Registers This Hotel This Room My Head 10 min 1 min 4

Disks Secondary storage device of choice. Main advantage over tapes: random access vs. sequential. Also, they work. (Tapes deteriorate over time) Data is stored and retrieved in units called disk blocks or pages. Unlike RAM, time to retrieve a disk page varies depending upon location on disk. Therefore, relative placement of pages on disk has major impact on DBMS performance! Anatomy of a Disk The platters spin (say, 150 rps). The arm assembly is moved in or out to position a head on a desired track. Tracks under heads make a cylinder (imaginary!). Disk head Only one head reads/writes at any one time. Arm assembly Block size is a multiple of sector size (which is fixed). Newer disks have several zones, with more data on outer tracks. Arm movement Spindle Tracks Sector Platters 5

Accessing a Disk Page 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) Seek time and rotational delay dominate. Seek time varies from about 1 to 20msec Rotational delay varies from 0 to 10msec Transfer rate is < 1msec per 4KB page Key to lower I/O cost: reduce seek/rotation delays! Transfer Hardware vs. software solutions? Rotate Wait Transfer Also note: For shared disks most time spent waiting in queue for access to arm/controller Seek Rotate Seek Arranging Pages on Disk `Next block concept: blocks on same track, followed by blocks on same cylinder, followed by blocks on adjacent cylinder Blocks in a file should be arranged sequentially on disk (by `next ), to minimize seek and rotational delay. For a sequential scan, pre-fetching several pages at a time is a big win! Also, modern controllers do their own caching. 6

Disk Space Management Lowest layer of DBMS software manages space on disk (using OS file system or not?). Higher levels call upon this layer to: allocate/de-allocate a page read/write a page Best if a request for a sequence of pages is satisfied by pages stored sequentially on disk! Higher levels don t need to know if/how this is done, or how free space is managed. 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 Data must be in RAM for DBMS to operate on it! Buffer Mgr hides the fact that not all data is in RAM 7

When a Page is Requested... Buffer pool information table contains: <frame#, pageid, pin_count, dirty> If requested page is not in pool: Choose a frame for replacement (only un-pinned pages are candidates) If frame is dirty, write it to disk Read requested page into chosen frame Pin the page and return its address. If requests can be predicted (e.g., sequential scans) pages can be pre-fetched several pages at a time! More on Buffer Management Requestor of page must unpin it, and indicate whether page has been modified: dirty bit is used for this. Page in pool may be requested many times, a pin count is used. A page is a candidate for replacement iff pin count = 0 ( unpinned ) CC & recovery may entail additional I/O when a frame is chosen for replacement. (Write- Ahead Log protocol; more later.) 8

Buffer Replacement Policy Frame is chosen for replacement by a replacement policy: Least-recently-used (LRU), MRU, Clock, etc. Policy can have big impact on # of I/O s; depends on the access pattern. LRU Replacement Policy Least Recently Used (LRU) for each page in buffer pool, keep track of time last unpinned replace the frame which has the oldest (earliest) time very common policy: intuitive and simple Problems? Problem: Sequential flooding 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). 9

Clock Replacement Policy An approximation of LRU. D(1) Arrange frames into a cycle, store C(1) one reference bit per frame When pin count goes to 0, reference bit set on. When replacement necessary: do { Questions: How like LRU? Problems? A(1) if (pincount == 0 && ref bit is off) choose current page for replacement; else if (pincount == 0 && ref bit is on) turn off ref bit; advance current frame; } until a page is chosen for replacement; B(p) DBMS vs. OS File System OS does disk space & buffer mgmt: why not let OS manage these tasks? Some limitations, e.g., files can t span disks. Note, this is changing --- OS File systems are getting smarter (i.e., more like databases!) Buffer management in DBMS requires ability to: pin a page in buffer pool, force a page to disk & order writes (important for implementing CC & recovery) adjust replacement policy, and pre-fetch pages based on access patterns in typical DB operations. 10

Summary Disks provide cheap, non-volatile storage. Random access, but cost depends on location of page on disk; important to arrange data sequentially to minimize seek and rotation delays. Buffer manager brings pages into RAM. Page stays in RAM until released by requestor. Written to disk when frame chosen for replacement (which is sometime after requestor releases the page). Choice of frame to replace based on replacement policy. Tries to pre-fetch several pages at a time. Summary (Contd.) DBMS vs. OS File Support DBMS needs features not found in many OS s, e.g., forcing a page to disk, controlling the order of page writes to disk, files spanning disks, ability to control pre-fetching and page replacement policy based on predictable access patterns, etc. 11