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

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

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 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?

Database Applications (15-415)

Storing Data: Disks and Files

Storing Data: Disks and Files

L9: Storage Manager Physical Data Organization

Storing Data: Disks and Files

Storing Data: Disks and Files

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

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

Disks, Memories & Buffer Management

STORING DATA: DISK AND FILES

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

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

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

Database Applications (15-415)

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

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

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.

CSE 190D Database System Implementation

Storing Data: Disks and Files

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

Managing Storage: Above the Hardware

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

Storing Data: Disks and Files

CSE 232A Graduate Database Systems

CS 405G: Introduction to Database Systems. Storage

Chapter 4 File Systems. Tanenbaum, Modern Operating Systems 3 e, (c) 2008 Prentice-Hall, Inc. All rights reserved

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

Unit 3 Disk Scheduling, Records, Files, Metadata

Unit 2 Buffer Pool Management

Unit 2 Buffer Pool Management

CMSC 424 Database design Lecture 12 Storage. Mihai Pop

Storage and File Structure

QUIZ: Is either set of attributes a superkey? A candidate key? Source:

Announcements. Reading Material. Recap. Today 9/17/17. Storage (contd. from Lecture 6)

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

ECS 165B: Database System Implementa6on Lecture 3

File Structures and Indexing

Chapter 11: Storage and File Structure. Silberschatz, Korth and Sudarshan Updated by Bird and Tanin

RAID in Practice, Overview of Indexing

Chapter 10 Storage and File Structure

CS220 Database Systems. File Organization

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

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

File. File System Implementation. Operations. Permissions and Data Layout. Storing and Accessing File Data. Opening a File

C13: Files and Directories: System s Perspective

Fall 2004 CS 186 Discussion Section Exercises - Week 2 ending 9/10

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

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

Chapter 11: File System Implementation. Objectives

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

Normalization, Generated Keys, Disks

Ch 11: Storage and File Structure

I/O Management and Disk Scheduling. Chapter 11

Mass-Storage Structure

Chapter 14: Mass-Storage Systems

Physical Storage Media

File. File System Implementation. File Metadata. File System Implementation. Direct Memory Access Cont. Hardware background: Direct Memory Access

Database Systems II. Secondary Storage

Operating Systems. Operating Systems Professor Sina Meraji U of T

System Structure Revisited

Silberschatz, et al. Topics based on Chapter 13

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

Chapter 11. I/O Management and Disk Scheduling

Module 13: Secondary-Storage

Chapter 12: Mass-Storage Systems. Operating System Concepts 8 th Edition,

Chapter 12: Secondary-Storage Structure. Operating System Concepts 8 th Edition,

Today: Secondary Storage! Typical Disk Parameters!

V. Mass Storage Systems

DATA STORAGE, RECORD and FILE STUCTURES

Mass Storage. 2. What are the difference between Primary storage and secondary storage devices? Primary Storage is Devices. Secondary Storage devices

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

I/O CANNOT BE IGNORED

CSE 4/521 Introduction to Operating Systems. Lecture 27 (Final Exam Review) Summer 2018

ECS 165B: Database System Implementa6on Lecture 2

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

CISC 7310X. C11: Mass Storage. Hui Chen Department of Computer & Information Science CUNY Brooklyn College. 4/19/2018 CUNY Brooklyn College

Overview of Storage & Indexing (i)

ICS Principles of Operating Systems

Chapter 10: Mass-Storage Systems

Tape pictures. CSE 30341: Operating Systems Principles

Long-term Information Storage Must store large amounts of data Information stored must survive the termination of the process using it Multiple proces

Part IV I/O System. Chapter 12: Mass Storage Structure

CSE 380 Computer Operating Systems

Chapter 2 Storage Disks, Buffer Manager, Files...

Chapter 10: Mass-Storage Systems

Chapter 1 Disk Storage, Basic File Structures, and Hashing.

Lecture 15 - Chapter 10 Storage and File Structure

Storage Devices for Database Systems

Storage and File Structure

CSE325 Principles of Operating Systems. Mass-Storage Systems. David P. Duggan. April 19, 2011

File-System Structure. Allocation Methods. Free-Space Management. Directory Implementation. Efficiency and Performance. Recovery

Preview. Memory Management

Transcription:

Outlines Chapter 2 Storage Structure Instructor: Churee Techawut 1) Structure of a DBMS 2) The memory hierarchy 3) Magnetic tapes 4) Magnetic disks 5) RAID 6) Disk space management 7) Buffer management 8) formats 9) Record formats CS (204)321 Database System I Structure of a DBMS (with some simplification) Structure of a DBMS (with some simplification) Query optimizer Uses information about how the data is stored to produce an efficient execution plan for evaluating the query. Execution plan A blueprint for evaluating a query, and is usually represented as a tree of relational operators. File and access methods Includes a variety of S/W for supporting the concept of a file, which is a collection of pages or a collection of records. Typically supports file of unordered pages as well as indexes. Source: Ramakrishnan R. & Gehrke J. (2000) Database Management Systems Structure of a DBMS (with some simplification) The Memory Hierarchy Buffer manager Bring pages in from disk to main memory. Disk space manager Deals with management of space on disk, where the data is stored. Transaction manager, lock manager, and recovery manager Supports concurrency and crash recovery by scheduling user requests and maintaining log of all changes to the database. Slower devices Less expensive Request for data Larger storage CPU CACHE MAIN MEMORY MAGNETIC DISK TAPE Data satisfying request Primary storage Secondary storage Tertiary storage 1 of 7

Characteristics of magnetic tapes: Magnetic Tapes The structure of a disk in simplified form. Inexpensive Store very large amounts of data. Good choice for archival storage used for maintaining data for a long period but do not expect to access it very often Support sequential access - stepping through all the data in order and cannot directly access a given location on tape. Block Unsuitable for storing operational data, but mostly used to back up operational data periodically. Source: Silberschatz A., Korth H., Sudarchan S. (2002) Database System Concepts Magnetic disks support direct access to a desired location and are widely used for database applications. Data is store on disk in units called disk blocks. Blocks are arranged in concentric rings called tracks, on one or more platters (single-sided or double sided). Each track is divided into arcs called sectors. The set of all tracks with the same diameter is called a cylinder. An array of disk heads, is moved as a unit. When one head is positioned over a block, the other heads are in identical position with respect to their platters. A disk controller manages the movement of the arm assembly and transferring of data to and from the disk surfaces. The time to access a disk block has several components: Access time = Seek time + Rotational delay + Transfer time Seek time The time taken to move the disk heads to the track on which a desired block is located. Rotational delay The waiting time for the desired block to rotate under the disk head. (Usually less than seek time) Transfer time The time for the disk to rotate over the block. Example: The seek time is 60 milliseconds (msec), rotation time is 12.5 msec., and transfer rate is 250 characters per msec. Find the access time if the length of the data, which is going to read, is 1000 characters. Access time = Seek time + Rotational delay + Transfer time = 60 + 12.5 + (1000/250) = 60 + 12.5 + 4 = 76.5 msec. Performance implications of disk structure: 1. Data must be in memory for the DBMS to operate on it. 2. The unit for data transfer between disk and main memory is a block; if a single item on a block is needed, the entire block is transferred. Reading or writing a disk clock is called an I/O (for input/output) operation. 3. The time to read or write a block varies, depending on the location of the data 2 of 7

RAID Note: Time taken for database operations is affected significantly by how data is stored on disks. Sequential access minimizes seek time and rotational delay and is much faster than random access. The Redundant Arrays of Independent Disks (RAID) is disk organization techniques that manage a large numbers of disks, providing a view of a single disk of high capacity and high speed by using multiple disks in parallel, and high reliability by storing data redundantly, so that data can be recovered even if a disk fails. e.g. mirroring Two identical copies of the data on two different disks are maintained. RAID Data stripping The data is segmented into equal-size partitions distributed over multiple disks. Redundancy Disks have a higher failure probability early and late in their lifetimes. Mean-time-to-failure (MTTF) is a failure probability during the actual usage time of the storage system. MTTF affects the reliability of a disk. If a disk fails, the redundant information is used to reconstruct the data on the failed disk. Redundancy can immensely increase the MTTF of a disk array. The role of disk space manager: manages space on disk supports the concept of a page as a unit of data provides commands to allocate or deallocate a page, and read or write page. The size of a page is chosen to be the size of a disk block s are stored as disk blocks. Reading or writing a page can be done in one disk I/O. Useful capability: Allocate a sequence of pages as a contiguous sequence of blocks to hold data. This capability is essential for exploiting the advantages of sequential accessing disk blocks. The disk space manager hides details of the underlying hardware and allows higher levels of the s/w to think of the data as a collection of pages. Managing space on disk: Keeping track of free blocks A database grows and shrinks as records are inserted and deleted over time. It is likely that blocks are initially allocated sequentially on disk, subsequent allocations and deallocations could in general create holes. 3 of 7

Keeping track of free blocks (continued) Two ways to keep track of block usage is to maintain: (1) A list of free blocks - Deallocating blocks are added to the free list for future use. (2) Bitmap - Indicating whether a block is in use or not - One bit for each disk block - Allowing fast identification and allocation of contiguous areas on disk Using OS file systems to manage disk space Operating system supports the abstraction of a file as a sequence of bytes. OS translates requests Read byte i of file f into Read block m of track t of cylinder c of disk d. The entire database could reside in one or more OS files for which a number of blocks are allocated (by the OS) and initialized. The disk space manager is then responsible for managing the space in these OS files. Using OS file systems to manage disk space (continued) Note: Using OS file is not popular for disk space management because different OS platforms has different disk space management and typical OS files cannot span disk devices. DBMS requires portability and may want to access a large single file. The role of buffer manager: Brings pages from disk to main memory as needed. Uses replacement policy to decide which page to replace. Manages the available main memory by partitioning it into a collection of pages or buffer pool. The main memory pages in the buffer pool are called frames. Disk page Free frame If a requested page is not in the pool and the pool is full, the buffer manager s replacement policy controls which existing page is replaced. requests from higher-level code DB MAIN MEMORY DISK pin_count and dirty variables: pin_count dirty pin_count = the no. of times that the page currently in a given frame has been requested but not released Incrementing pin_count is called pinning the page. Decrementing pin_count is called unpinning the page. dirty = the boolean variable indicating whether the page has been modified since it was brought into the buffer pool from disk. request & release 4 of 7

The buffer replacement policies: The replacement can affect the time taken for database operations. Different policies are suitable in different situations. Least recently used (LRU) A queue of pointers 1 st queue Clock replacement Similar behavior as LRU, but less overhead. Clock s face current variable = clock hand N 1 N= No. of buffer frame 2 3 4 5 pin_count = 0 end of queue A page that becomes a candidate for replacement Current frame is considered for replacement. If the frame is not chosen for replacement or pin_count >0, current is incremented and the next frame is considered. Other replacement policies include: first in first out (FIFO) Higher levels of the DBMS see data as a collection of records. We consider how a collection of records can be arranged on a page. most recently used (MRU) Random record 2 A record is identified by record id or rid (page id, slot number). Alternative approaches to managing slots on a page: Record slots are uniform in the same length and can be arranged within a page. Some slots are occupied or unoccupied by records. How we keep track of empty slots and how we locate all records on a page? 5 of 7

Two alternative hinges: First alternative: Store records in the first N slots (where N is the number of records on the page). record 2 Slot 3 record 3 Whenever a record is deleted,. record 2 Slot 3 record 3.. we move the last record on the page into the vacated slot. Slot 3 record 3 Second alternative: Use an array of bits to handle deletions, one bit per slot. Slot 3 Slot j header 1 0 1 j j 2 1 Number of slots To locate records, the page requires scanning the bit array to find slots whose bit is on. When a record is deleted, its bit is turned off. The page cannot be divided into a fixed collection of slots. DATA AREA rid=(i,n) rid=(i,1) PAGE i Problem is that when a new record is to be inserted, we have to find an empty slot of just the right length. rid=(i,2) length=24 Important rules: 1) To insert a record, we must allocate just the right amount of space for it. 2) To delete a record, we must move records to fill the hole created by the deletion to ensure the contiguousness of all free space. The most flexible organization for variable-length records is to maintain a directory of slots (maintain pointers). Pointer to start of free space FREE SPACE SLOT DIRECTORY No. of entries in slot directories N 2 1 20 16 24 N 6 of 7

How to organize fields within record. We must consider whether the fields of the record are of fixed or variable length. No. of fields and field types is stored in the system catalog. Alternative approaches to organization of records: Each field has a fixed length (that is the value in this field is of the same length in all records), and the number of fields is also fixed. The fields of such a record can be stored consecutively. The address of a particular field can be calculated using information about the lengths of preceding fields, which is available in the system catalog. Organization of records with fixed-length fields F1 F2 F3 F4 L1 L2 L3 L4 Base address (B) Address = B+L1+L2 Fi = field i Li = length of field i This organization stores fields consecutively, separated by delimiters. It requires a scan of the record in order to locate a desired field. At the beginning of a record, some space is reserved for use as an array of integer offsets the i th integer in this array is the starting address of the i th field value relative to the start of the record. Organization for variable-length fields F1 $ F2 $ F3 $ F4 Fields delimited by special symbol $ Fi = field i F1 F2 F3 F4 Array of field offsets 7 of 7