PS2 out today. Lab 2 out today. Lab 1 due today - how was it?

Similar documents
(Storage System) Access Methods Buffer Manager

6.830 Lecture 8 10/2/2017. Lab 2 -- Due Weds. Project meeting sign ups. Recap column stores & paper. Join Processing:

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

University of Waterloo Midterm Examination Sample Solution

CMSC424: Database Design. Instructor: Amol Deshpande

Each time a file is opened, assign it one of several access patterns, and use that pattern to derive a buffer management policy.

CSE 444: Database Internals. Lectures 5-6 Indexing

Physical Disk Structure. Physical Data Organization and Indexing. Pages and Blocks. Access Path. I/O Time to Access a Page. Disks.

Overview of Storage and Indexing

6.033 Computer System Engineering

Column Stores vs. Row Stores How Different Are They Really?

Overview of Storage and Indexing

External Sorting Implementing Relational Operators

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

Lecture 8 Index (B+-Tree and Hash)

L9: Storage Manager Physical Data Organization

STORING DATA: DISK AND FILES

CMSC 424 Database design Lecture 13 Storage: Files. Mihai Pop

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

Faloutsos 1. Carnegie Mellon Univ. Dept. of Computer Science Database Applications. Outline

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

Disks, Memories & Buffer Management

Database Applications (15-415)

Midterm Review CS634. Slides based on Database Management Systems 3 rd ed, Ramakrishnan and Gehrke

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

CS3600 SYSTEMS AND NETWORKS

Administriva. CS 133: Databases. General Themes. Goals for Today. Fall 2018 Lec 11 10/11 Query Evaluation Prof. Beth Trushkowsky

Database Technology. Topic 7: Data Structures for Databases. Olaf Hartig.

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

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2008 Quiz II

Data on External Storage

RAID in Practice, Overview of Indexing

EXTERNAL SORTING. Sorting

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

Something to think about. Problems. Purpose. Vocabulary. Query Evaluation Techniques for large DB. Part 1. Fact:

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2015 Quiz I

(Note that these notes will be use for the next 2-3 lectures)

Introduction to Data Management. Lecture #13 (Indexing)

Hash-Based Indexing 165

Advanced Database Systems

Database Management System

NOTE: sorting using B-trees to be assigned for reading after we cover B-trees.

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

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Database Systems: Fall 2009 Quiz I Solutions

CS698F Advanced Data Management. Instructor: Medha Atre. Aug 11, 2017 CS698F Adv Data Mgmt 1

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

Review: Memory, Disks, & Files. File Organizations and Indexing. Today: File Storage. Alternative File Organizations. Cost Model for Analysis

Storage hierarchy. Textbook: chapters 11, 12, and 13

ECE331: Hardware Organization and Design

Memory: Page Table Structure. CSSE 332 Operating Systems Rose-Hulman Institute of Technology

Data Storage. Query Performance. Index. Data File Types. Introduction to Data Management CSE 414. Introduction to Database Systems CSE 414

CompSci 516: Database Systems

Hash table example. B+ Tree Index by Example Recall binary trees from CSE 143! Clustered vs Unclustered. Example

Advanced Database Systems

Kathleen Durant PhD Northeastern University CS Indexes

1. With respect to space, linked lists are and arrays are.

15-415/615 Faloutsos 1

Next-Generation Parallel Query

Administrivia. CS 133: Databases. Cost-based Query Sub-System. Goals for Today. Midterm on Thursday 10/18. Assignments

Chapter 18 Indexing Structures for Files

Overview of Storage and Indexing

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

CS 31: Intro to Systems Virtual Memory. Kevin Webb Swarthmore College November 15, 2018

File Structures and Indexing

Introduction to Database Systems CSE 414. Lecture 26: More Indexes and Operator Costs

Indexing: Overview & Hashing. CS 377: Database Systems

Dtb Database Systems. Announcement

Hash-Based Indexing 1

Overview of Storage and Indexing

CMPUT 391 Database Management Systems. Query Processing: The Basics. Textbook: Chapter 10. (first edition: Chapter 13) University of Alberta 1

Implementation of Relational Operations: Other Operations

Datenbanksysteme II: Caching and File Structures. Ulf Leser

Storing Data: Disks and Files

Database Applications (15-415)

Step 4: Choose file organizations and indexes

Overview of Storage and Indexing

System R Optimization (contd.)

CMSC424: Database Design. Instructor: Amol Deshpande

Systems Infrastructure for Data Science. Web Science Group Uni Freiburg WS 2014/15

Query Processing Models

Database Applications (15-415)

EECS 482 Introduction to Operating Systems

Evaluation of Relational Operations: Other Techniques

External Sorting. Chapter 13. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

Evaluation of Relational Operations

University of California, Berkeley. CS 186 Introduction to Databases, Spring 2014, Prof. Dan Olteanu MIDTERM

Find the block in which the tuple should be! If there is free space, insert it! Otherwise, must create overflow pages!

Indexing. Week 14, Spring Edited by M. Naci Akkøk, , Contains slides from 8-9. April 2002 by Hector Garcia-Molina, Vera Goebel

CMSC 424 Database design Lecture 12 Storage. Mihai Pop

Announcement. Reading Material. Overview of Query Evaluation. Overview of Query Evaluation. Overview of Query Evaluation 9/26/17

CARNEGIE MELLON UNIVERSITY DEPT. OF COMPUTER SCIENCE DATABASE APPLICATIONS

Access Methods. Basic Concepts. Index Evaluation Metrics. search key pointer. record. value. Value

Tree-Structured Indexes

Evaluation of relational operations

Storage and Indexing

Chapter 13: Query Processing

Algorithm Performance Factors. Memory Performance of Algorithms. Processor-Memory Performance Gap. Moore s Law. Program Model of Memory I

CS 4604: Introduction to Database Management Systems. B. Aditya Prakash Lecture #10: Query Processing

Evaluation of Relational Operations: Other Techniques. Chapter 14 Sayyed Nezhadi

Overview of Storage & Indexing (i)

Transcription:

6.830 Lecture 7 9/25/2017 PS2 out today. Lab 2 out today. Lab 1 due today - how was it? Project Teams Due Wednesday Those of you who don't have groups -- send us email, or hand in a sheet with just your name on it saying you are looking for partners. Team Meetings In 2 Weeks Show slide -- where are we Last time: Iterator model for executing queries, and intro to heap files and B+Trees Today: cost estimation basics access methods What's the "cost" of a particular plan? CPU cost (# of instructions) Spinning Disk I/O cost (# of pages read, # of seeks) Random I/O disk = page read + seek Flash disk - 1 ghz == 1 billions instrs / sec, 1 nsec / instr - 100 MB / sec = 10 nsec / byte - 10 msec / io operation = 100 io ops / sec - 300-500 MB/sec seq rd/write - 10K + random iops / sec (100 usec / io operation) 4K pages ~= 40 MB/sec Random I/O can be a real killer (10 million instrs/seek). When does a disk need to seek?

Which do you think dominates in most database systems? (Depends. Not always disk I/O. Typically vendors try to configure machines so they are 'balanced'. Can vary from query to query. Because of sequential access methods, buffer pool, we can often end up CPU bound.) For example, fastest TPC-H benchmark result (data warehousing benchmark), on 10 TB of data, uses 1296 74 GB disks, which is 100 TB of storage. Add'l storage is partly for indices, but partly just because they needed add'l disk arms. 72 processors, 144 cores -- ~10 disks / processor! But, if we do a bad job, random I/O can kill us! 100 tuples/page select * from 10 pages RAM emp, dept., kids 10 KB/page where e.sal > 10k emp.dno = dept.dno 10 ms seek time e.eid = kids.eid 100 MB/sec I/O dept = 100 records = 1 page = 10 KB emp = 10K = 100 pages = 1 MB kids = 30K = 300 pages = 3 MB 1000 / 100 \ 1000 d σ sal>10k e 1st Nested loops join -- 100,000 predicate ops; 2nd nested loops join -- 30,000,000 predicate ops

Let's look at # disk I/Os assuming LRU and no indices Join 1 if d is outer: 1 scan of d 100 sec scans of e (100 x 100 pg. reads) -- cache doesn't benefit since e doesn't fit 2.1 secs 1 scan of e: 1 seek + read in 1MB 10 ms + 1 MB / 100 MB/sec = 20 msec 20 ms x 100 depts = 2 sec 10 msec seek to start of d and read into memory if d is inner read page of e -- 10 msec read all of d into RAM -- 10 msec seek back to e -- 10 sec scan rest of e -- 10 msec, joining with d in memory Because d fits into memory, total cost is just 40 msec NL # predicates evaluated doesn't depend on inner vs outer, but I/O cost does (due to caching effect!) Join 2 k inner: 1000 scans of 300 pages 3 / 100 = 30 msec + 10 msec seek = 40 x 1000 = 40 sec if plan is pipelined, k must be inner So what will be cached? That's the job of the buffer pool.

Buffer pool is a cache for memory access. Typically caches pages of files / indices. Convenient "bottleneck" through which references to underlying pages go. When page is in buffer pool, don't need to read from disk. Updates can also be cached. What is optimal buffer pool caching strategy? Always LRU? No. What if some relation doesn't fit into memory? (MRU preferred) 2 pages RAM, 3 pages of a relation R -- a, b c, accessed sequentially in a loop Access RAM 1 2 3 4 1 a a c c 2 b b a ==> always evicting page we are about to access! Note that MRU would hit on 2/3 What if I know I will not be accessing a relation again in a query? Are some records higher value than others? Because data is large, we may want to use "access methods" that allow us to get the data we want with a minimum of I/Os. Especially true if just trying to look up one record (e.g., a particular employee) in a large database. These access methods are dictionary structures we are familiar with (e.g., hash tables, trees), that are specially built to be "external" -- that is, disk resident. These are indices. Hence, database system uses indices when it can.

Why do I say "when it can"? (Some indices are good for different things -- e.g., hash tables don't support range queries) Why not create indices on every attribute? Update costs! (Indices are big, and so are typically stored on disk.) Lets look at different types of access methods: types of access methods heapfiles (sorted files) index files leaves as data (primary index) leaves as rids (secondary index) clustered vs. unclustered types of indexes hash files b-trees r-trees... tradeoffs between different storage representations scan vs. search vs. insert vs. delete N - number of records P - pages in index/file R - pages in range (units are # I/ Os) Heap File Hash File B+Tree Search P/2 O(1) O(logb N) Scan P - O(logb N) + R Delete P/2 O(1) O(logb N)

heap files search cost ~= scan cost ~= delete cost - linked list - directory - array of objs **** STUDY BREAK **** hash files search cost ~= 1 insert cost ~= 1 delete cost ~= 1 range scan is equal to sequential scan map(key) -> {rid} -- could also store map(key) -> {record} suppose we have a hash-table that for employees stored on disk hashed on the 'name' attribute. h(name) -> {1..k} h(x) = x mod k; //not very uniform but works (consider performance when number of distinct values is small, or all numbers even) We have k buckets, and one page per bucket. Store to pages by hashing, appending the record to that page. k chosen to fit in memory. Then, if a query looks for 'mike', we can find him in a single I/O (we know exactly where to go to find him.)

(Show slide) How many buckets do we need? (hard to tell!) Too many? -- Wasteful Too few? -- Long chains that we have to follow Extensible hashing: Gave example before -- in principle, we can overflow a page, in which case we need an overflow chain. These overflow chains can get long and slow down the performance of our algorithm. So, instead, we split hash buckets when they get full. We do this with a family of hash functions, where we switch to the next level when we get too many in the current level. define h(v) = {0, 1,..., b} h_k(v) = h(v) mod 2^k h_1(v) = {0,1} h_2{v} = {0, 1, 2, 3}... Maintain a current hash function, its "levels", and a directory that tells you where each bucket is on disk example:

(Show slide) (Lecture ends here -- B+Trees next time) B+-Trees: Show example tree: Not going to discuss details of how insertion/splitting/rebalancing work. Discussion points: - What is point of link pointers? - Why not store data in intermediate nodes - Page occupancy (why does this matter) - Key size?

- Balanced (why important?) - How many levels in practice disk page = 4096 bytes; values 4 bytes; ptrs 4 bytes = 512 ptrs / node --> 512^4 = 68 billion - log(n) for lookup/insert/delete; how many I/Os in practice? (1, maybe 2, since top levels will fit in RAM, E.g., top 2 levels are just 513 * 4096 bytes == 2MB) - Scan is random, unless index is clustered - Node format "Fill factor": percentage of each page that is used. Every node except root node is at least 50% full Why would we not want this to be 100%? Ideally, 67% full (where from)? Can be clustered or unclustered clustered means that data is physically stored in order of index often, leaves of index contain actual data records Lots of other indexes, e.g., R+Trees.