DBMS 2001Notes 2: Hardware1 Principles of Database Management Systems Pekka Kilpeläinen (after Stanford CS245 slide originals by Hector Garcia-Molina,

Slides:



Advertisements
Similar presentations
CPS216: Data-Intensive Computing Systems Data Access from Disks Shivnath Babu.
Advertisements

- Dr. Kalpakis CMSC Dr. Kalpakis 1 Outline In implementing DBMS we need to answer How should the system store and manage very large amounts of data?
CS 400/600 – Data Structures External Sorting.
Storing Data: Disks and Files: Chapter 9
CS 277 – Spring 2002Notes 21 CS 277: Database System Implementation Notes 02: Hardware Arthur Keller.
CS 245Notes 21 CS 245: Database System Principles Notes 02: Hardware Hector Garcia-Molina.
Data Storage John Ortiz. Lecture 17Data Storage2 Overview  Database stores data on secondary storage  Disk has distinct storage and access characteristics.
1 External Sorting Chapter Why Sort?  A classic problem in computer science!  Data requested in sorted order  e.g., find students in increasing.
The Memory Hierarchy fastest, but small under a microsecond, random access, perhaps 512Mb Typically magnetic disks, magneto­ optical (erasable), CD­ ROM.
Using Secondary Storage Effectively In most studies of algorithms, one assumes the "RAM model“: –The data is in main memory, –Access to any item of data.
The Memory Hierarchy fastest, perhaps 1Mb
Storage. The Memory Hierarchy fastest, but small under a microsecond, random access, perhaps 2Gb Typically magnetic disks, magneto­ optical (erasable),
CS4432: Database Systems II Data Storage - Lecture 2 (Sections 13.1 – 13.3) Elke A. Rundensteiner.
1 Advanced Database Technology February 12, 2004 DATA STORAGE (Lecture based on [GUW ], [Sanders03, ], and [MaheshwariZeh03, ])
Disk Access Model. Using Secondary Storage Effectively In most studies of algorithms, one assumes the “RAM model”: –Data is in main memory, –Access to.
SECTION 13.3 Eilbroun Benjamin CS 257 – Dr. TY Lin SECONDARY STORAGE MANAGEMENT.
13.2 Disks Mechanics of Disks Presented by Chao-Hsin Shih Feb 21, 2011.
CPSC-608 Database Systems Fall 2008 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #6.
1 Lecture 26: Storage Systems Topics: Storage Systems (Chapter 6), other innovations Final exam stats:  Highest: 95  Mean: 70, Median: 73  Toughest.
CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Professor Elke A. Rundensteiner.
1 CS143: Disks and Files. 2 System Architecture CPU Main Memory Disk Controller... Disk Word (1B – 64B) ~ x GB/sec Block (512B – 50KB) ~ x MB/sec System.
SECTIONS 13.1 – 13.3 Sanuja Dabade & Eilbroun Benjamin CS 257 – Dr. TY Lin SECONDARY STORAGE MANAGEMENT.
CS4432: Database Systems II Lecture 2 Timothy Sutherland.
CPSC-608 Database Systems Fall 2009 Instructor: Jianer Chen Office: HRBB 309B Phone: Notes #5.
Using Secondary Storage Effectively In most studies of algorithms, one assumes the "RAM model“: –The data is in main memory, –Access to any item of data.
CPSC-608 Database Systems Fall 2010 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #5.
CS 4432lecture #31 CS4432: Database Systems II Lecture #3 Using the Disk, and Disk Optimizations Professor Elke A. Rundensteiner.
1 CS222: Principles of Database Management Fall 2010 Professor Chen Li Department of Computer Science University of California, Irvine Notes 01.
SECTIONS 13.1 – 13.3 Sanuja Dabade & Eilbroun Benjamin CS 257 – Dr. TY Lin SECONDARY STORAGE MANAGEMENT.
Storage. The Memory Hierarchy fastest, but small under a microsecond, random access, perhaps 8Gb Typically magnetic disks, magneto­ optical (erasable),
Storage. The Memory Hierarchy fastest, but small under a microsecond, random access, perhaps 512Mb Access times in milliseconds, great variability. Unit.
Introduction to Database Systems 1 The Storage Hierarchy and Magnetic Disks Storage Technology: Topic 1.
External Sorting Problem: Sorting data sets too large to fit into main memory. –Assume data are stored on disk drive. To sort, portions of the data must.
CS4432: Database Systems II Data Storage (Better Block Organization) 1.
CS 352 : Computer Organization and Design University of Wisconsin-Eau Claire Dan Ernst Storage Systems.
Chapter 2 Data Storage How does a computer system store and manage very large volumes of data ?
Lecture 11: DMBS Internals
1 Secondary Storage Management Submitted by: Sathya Anandan(ID:123)
Chapter 111 Chapter 11: Hardware (Slides by Hector Garcia-Molina,
Storage.
Chapter 2. Data Storage Chapter 2.
Indexing.
External Storage Primary Storage : Main Memory (RAM). Secondary Storage: Peripheral Devices –Disk Drives –Tape Drives Secondary storage is CHEAP. Secondary.
1 Data Storage (Chap. 11) Based on Hector Garcia-Molina’s slides.
CPSC 404, Laks V.S. Lakshmanan1 External Sorting Chapter 13 (Sec ): Ramakrishnan & Gehrke and Chapter 11 (Sec ): G-M et al. (R2) OR.
CPSC 404, Laks V.S. Lakshmanan1 External Sorting Chapter 13: Ramakrishnan & Gherke and Chapter 2.3: Garcia-Molina et al.
11.1Database System Concepts. 11.2Database System Concepts Now Something Different 1st part of the course: Application Oriented 2nd part of the course:
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
CS4432: Database Systems II Data Storage 1. Storage in DBMSs DBMSs manage large amounts of data How does a DBMS store and manage large amounts of data?
CPSC-608 Database Systems Fall 2015 Instructor: Jianer Chen Office: HRBB 315C Phone: Notes #5.
DMBS Internals I February 24 th, What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the.
DMBS Internals I. What Should a DBMS Do? Store large amounts of data Process queries efficiently Allow multiple users to access the database concurrently.
DMBS Architecture May 15 th, Generic Architecture Query compiler/optimizer Execution engine Index/record mgr. Buffer manager Storage manager storage.
1 CSE232A: Database System Principles Hardware. Data + Indexes Database System Architecture Query ProcessingTransaction Management SQL query Parser Query.
CPS216: Advanced Database Systems Notes 03: Data Access from Disks Shivnath Babu.
1 Lecture 16: Data Storage Wednesday, November 6, 2006.
CS 245Notes 21 Database System Principles Notes 02: Hardware.
1 Query Processing Exercise Session 1. 2 The system (OS or DBMS) manages the buffer Disk B1B2B3 Bn … … Program’s private memory An application program.
1 Components of the Virtual Memory System  Arrows indicate what happens on a lw virtual address data physical address TLB page table memory cache disk.
CS422 Principles of Database Systems Disk Access Chengyu Sun California State University, Los Angeles.
Storage and Disks.
Lecture 16: Data Storage Wednesday, November 6, 2006.
Disks and RAID.
CS 554: Advanced Database System Notes 02: Hardware
CPSC-608 Database Systems
Lecture 11: DMBS Internals
Sanuja Dabade & Eilbroun Benjamin CS 257 – Dr. TY Lin
Persistence: hard disk drive
CPS216: Advanced Database Systems Notes 04: Data Access from Disks
CS 245: Database System Principles Notes 02: Hardware
Presentation transcript:

DBMS 2001Notes 2: Hardware1 Principles of Database Management Systems Pekka Kilpeläinen (after Stanford CS245 slide originals by Hector Garcia-Molina, Jeff Ullman and Jennifer Widom)

DBMS 2001Notes 2: Hardware2 Outline Hardware: Disks Access Times Example - Megatron 747 External sorting Other Topics: – Optimizing disk usage

DBMS 2001Notes 2: Hardware3 P MC Typical Computer Secondary Storage... P: processor M: main memory C: disk controller Bus

DBMS 2001Notes 2: Hardware4 Main memory (+ cache) Disk Tertiary Storage Memory Hierarchy: Capacities and access times Gigabytes Terabytes Megabytes s 10 ms = s 100 ns = s

DBMS 2001Notes 2: Hardware5 CPU vs. Disk Speed CPU: 100  500  1000 MIPS –Main memory access  sec. DISK read/write approx. 10 … 30 ms CPU executes roughly 10 6 instructions in the time of a disk access –disk access times do not shrink in proportion to CPU speed-up  disk I/O major DBMS concern

DBMS 2001Notes 2: Hardware6 Typical Disk 1…n rotating platters (of two surfaces); Surfaces accessed by heads (moving together), divided into concentric tracks. Tracks under the heads at the same time form a cylinder. Tracks are divided into sectors separated by gaps. …

DBMS 2001Notes 2: Hardware7 Top View: tracks on a surface sector track gap

DBMS 2001Notes 2: Hardware8 “Typical” Numbers Diameter: " Cylinders: (floppy:40) Surfaces:1 (CD, old floppy)  (=tracks/cyl) 2 (floppy, DVD)  30 Sector Size:0.5 … 4KB … 50KB Capacity:1.44 MB (floppy)... several GBs

DBMS 2001Notes 2: Hardware9 Physical vs. Logical I/O Sector: indivisible unit of disk I/O Blocks –logical (DBMS/OS) units of disk storage –transferred btw disk and main memory buffers –typically 4… 56 KB, consisting of one or more sectors

DBMS 2001Notes 2: Hardware10 Disk Access Time block X in memory ? I want block X

DBMS 2001Notes 2: Hardware11 Time = Seek Time + Rotational Delay + Transfer Time + Other

DBMS 2001Notes 2: Hardware12 Seek Time S 3x … 20x x 1N Cylinders Traveled Time Real seek time Simplified approximation

DBMS 2001Notes 2: Hardware13 Average Random Seek Time E(S) E(S) = 1/N  1/N  SEEKTIME (i  j) NN i=1 j=1 “Typical” E(S): ms  (approx.) 1/3 SEEKTIME (1  N)

DBMS 2001Notes 2: Hardware14 Rotational Delay R Head Here Block I Want

DBMS 2001Notes 2: Hardware15 Average Rotational Delay E(R) E(R) = 1/2 x full rotation time “Typical” rotation speed 3600 RPM  full rotation in 1/60 s  E(R) = 1/120 s = 8.33 ms

DBMS 2001Notes 2: Hardware16 Transfer Rate: t “typical” t: MB/second transfer time: (block size)/t Other Delays: CPU time to issue I/O Contention for controller Contention for bus, memory “Typical” Value  0

DBMS 2001Notes 2: Hardware17 So far: Random Block Access What about: Reading “Next” block?

DBMS 2001Notes 2: Hardware18 If we do things right (e.g., Arrange by Cylinders, Double Buffer …) Time to get = Block Size + Negligible block t - skip gap - switch track - once in a while, next cylinder

DBMS 2001Notes 2: Hardware19 Rule ofRandom I/O: Expensive Thumb Sequential I/O: Much less Ex:1 KB Block »Random I/O:  20 ms. »Sequential I/O:  1 ms.

DBMS 2001Notes 2: Hardware20 Cost for Writing similar to Reading …. unless we want to verify! need to add (full) rotation + Block size t

DBMS 2001Notes 2: Hardware21 To Modify a Block? To Modify Block: (a) Read Block (b) Modify in Memory (c) Write Block [(d) Verify?]

DBMS 2001Notes 2: Hardware22 4 platters, 8 surfaces 2 13 = 8192 cylinders (or tracks/surface) 2 8 = 256 sectors/track –90% of track length for data, 10% for gaps 2 9 = 512 bytes/sector  capacity 2 3 x 2 13 x 2 8 x 2 9 = 2 33 = 8 GB An Example Megatron 747 Disk (Example 2.1 in book)

DBMS 2001Notes 2: Hardware23 Timing for Megatron 747 (Ex 2.3) Time to read a 4 KB block? –MIN: only transfer time: Read 8 sectors (a' 0.5 KB) and pass 7 gaps –How much does the disk need to rotate? For data 8/256 x 90% = 72/2560 rotation, for gaps 7/256 x 10% = 7/2560 rotation – 3840 RPM  1/64 s for one rotation  time (79/2560)/64 s, or about 0.5 ms (i.e. transfer speed approx. 8 MB/s)

DBMS 2001Notes 2: Hardware24 Maximum block access time Megatron 474 head movements: –1 ms to start&stop + 1 ms/500 cylinders MAX block access time: –SEEKTIME(1  8192) = /500 ms = 17.4 ms –full rotation: 1/64 s = 15.6 ms –transfer: 0.5 ms  33.5 ms

DBMS 2001Notes 2: Hardware25 Megatron 474: Average block access time AVG block access time: –AVG SEEKTIME: Assuming random access, avg head movement is 1/3 of all tracks  1 ms + 1/3 x 8191/500 ms = 6.5 ms –half rotation: 1/2 x 1/64 s = 7.8 ms –transfer: 0.5 ms  14.8 ms

DBMS 2001Notes 2: Hardware26 Outline Hardware: Disks Access Times Example: Megatron 747 External sorting Other Topics –Optimizing Disk Usage here

DBMS 2001Notes 2: Hardware27 Two-Phase Multiway Merge-Sort Sorting of files or relations is a recurrent task What if the data doesn't fit in main memory? Ex: Sort relation R of 10x byte tuples, using Megatron 747 disk and 50 MB main memory (M) for buffers (Ex. 2.5, , 2.14 in Book). –Block size 4 KB  40 tuples/block  R takes 10 7 /40 = 250,000 blocks  M can hold 50 x 2 20 /2 12 = 12,800 blocks MB 4 KB

DBMS 2001Notes 2: Hardware28 Sorted file Memory Sorted sublists Always move the smallest head elemenent to the ouput buffer... Merging Sorted Sublists is Easy

DBMS 2001Notes 2: Hardware29 One way to sort: Merge Sort (i) For each main-memory-sized chunk of R: - Read chunk - Sort in memory (say, using quicksort) - Write to disk sorted chunks (sublists) Memory R L1... L2 Ln

DBMS 2001Notes 2: Hardware30 (ii) Read all chunks + merge + write out Sorted file Memory Sorted sublists...

DBMS 2001Notes 2: Hardware31 Example: Sorting R (cont.) R fills memory 250,000/12,800=20 times (last time memory not full) Phase (i): 250,000 blocks first read, then written  500,000 block accesses. If in random order, time 500,000 x 15 ms = 125 minutes Phase (ii): Similarly 125 min; Total 250 min blocks of R blocks fitting in M

DBMS 2001Notes 2: Hardware32 How Large Files Can We Sort? Let B = block size, M = size of main memory available for sorting, R = size of each record  M/B buffers fit in memory; one for output  Phase (ii) can merge at most (M/B - 1) sublists, each created by sorting at most M/R records  M/R x (M/B - 1), roughly M 2 /(BxR) records

DBMS 2001Notes 2: Hardware33 M 2 /(BxR) in Practise? In our example, M = 50,000,000, B = 4096, R = 100  M 2 /(BxR) = 2500x10 12 /(4096 x 100) = 6.1 x 10 9 records, taking 0.61 terabytes of storage Pretty much! –Additional merge-phases can be added to cover even larger data sets.

DBMS 2001Notes 2: Hardware34 Optimizations Arranging sequentially accessed blocks by cylinders Pre-fetching buffers Mirrored Disks

DBMS 2001Notes 2: Hardware35 Arranging Blocks by Cylinders Consider our merge-sort example. The blocks of R can be stored on consecutive cylinders, and the 20 sorted sublists can be written likewise –Megatron 747 cylinder size 1 MB  Time to fill main memory (by 50 cylinders): AVG seek 6.5 ms + 49 one-cylinder seeks a' 1 ms + transfer time for 12,800 blocks a' 0.5 ms  transfer time to fill memory once 6.4 s; Seek times ignorable (if no other processes!)

DBMS 2001Notes 2: Hardware36 Arranging Blocks by Cylinders (cont.)  Phase (i) of multiway merge-sort dominated by the transfer time of reading & writing a memory-full of blocks 20 times: 20 x 2 x 6.4 s = 256 s = 4.3 min (vs. previous 125 minutes!)

DBMS 2001Notes 2: Hardware37 What about Phase (ii)? In the merge phase, a new block is read when one gets exhausted  blocks read in a somewhat random order But we wrote each sublist sequentially along cylinders! –We can utilize this by using larger buffers, holding entire tracks or even cylinders –To increase throughput, apply double buffering

DBMS 2001Notes 2: Hardware38 Double Buffering Problem: Have a File » Sequence of Blocks B1, B2, B3,... Have a Program » Process B1 » Process B2 » Process B3...

DBMS 2001Notes 2: Hardware39 Single Buffer Solution (1) Read B1  Buffer (2) Process Data in Buffer (3) Read B2  Buffer (4) Process Data in Buffer...

DBMS 2001Notes 2: Hardware40 SayP = time to process/block R = time to read in 1 block n = # blocks Single buffer time = n(P+R)

DBMS 2001Notes 2: Hardware41 Double Buffering Memory: Disk: ABCDGEFA B done process A C B done

DBMS 2001Notes 2: Hardware42 Say R  P What is processing time? P = Processing time/block R = IO time/block n = # blocks Double buffering time = nR Single buffering time = n(R+P)

DBMS 2001Notes 2: Hardware43 Cylinder-Sized Double-Buffering Consider implementing the merge-phase using two cylinder-sized (1 MB) buffers for each of our 20 sorted sublists Only one seek/cylinder (AVG 6.5 ms) + one full rotation for each of the 8 tracks of a cylinder (each 15.6 ms)  ms to read one buffer –repeated 1000 times to read entire relation  about 2.15 min to read all sublists

DBMS 2001Notes 2: Hardware44 Cylinder-Sized Double-Buffering (cont.) Writing the sorted relation can be arranged similarly  Time to output the buffers for the result also 2.15 min  Total time for multiway merge-sort 4.3 min (Phase i) min (Phase ii) = 8.6 minutes (vs. over 4 hours without these tricks!)

DBMS 2001Notes 2: Hardware45 Mirroring Disks Two or more disks holding identical copies of data –Optimizes: Can read blocks from whichever disk is faster. (Writing on each disk happens in parallel.) –Enhances reliability: A single disk crash does not cause loss of data. (RAID level 1)

DBMS 2001Notes 2: Hardware46 Using redundant disks RAID (Redundant Arrays of Independent Disks) –different versions, levels –Basic idea: One of the disks is redundant holding checksums for other disks –contents of crashed disks can be recovered from the checksums

DBMS 2001Notes 2: Hardware47 Error Recovery in Databases Log Current DBLast week’s DB More about this later

DBMS 2001Notes 2: Hardware48 Summary Secondary storage, mainly disks I/O times dominate DBMS processing I/Os should be avoided, especially random ones Summary