Inside database
Upcoming SlideShare
Loading in...5
×
 

Like this? Share it with your network

Share

Inside database

on

  • 1,587 views

An introduction to database management systems.

An introduction to database management systems.
Use internal study meeting named "DATABASE NO KIMOCHI WO SHIRU KAI" inside Cybozu.

Statistics

Views

Total Views
1,587
Views on SlideShare
1,538
Embed Views
49

Actions

Likes
0
Downloads
9
Comments
0

2 Embeds 49

http://wiki.dev.cybozu.co.jp 47
https://remote2tst.cybozu.co.jp 2

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Inside database Presentation Transcript

  • 1. Inside Database System Takashi HOSHINO Cybozu Labs
  • 2. Overview
    • Control/data Flow
    • DBMS
      • Query Processor
      • Storage Engine
        • Transaction Management
        • Buffer Cache Management
        • Data Structures
    • Storage
  • 3. Control/Data Flow Application DBMS OS Storage SQL/Records RW/Blocks
  • 4. DBMS Query Processor Storage Engine
  • 5. Query Processor Hector 2010 parse convert apply laws estimate result sizes consider physical plans estimate costs pick best execute {P1,P2,…..} {(P1,C1),(P2,C2)...} Pi answer SQL query parse tree logical query plan “ improved” l.q.p l.q.p. +sizes statistics
  • 6. Query Plan Example Hector 2010  B,D  R.A = “c”  S.E = 2 R S natural join
  • 7. Which Plan is Good? Hector 2010 R S T T R S S T R
  • 8. Storage Engine Transaction Management Buffer Cache Management Data Structures
  • 9. Transaction Management
    • Keep ACID property of data
      • Atomicity
      • Consistency
      • Isolation
      • Durability
    • Concurrency Control
    • Logging & Recovery
  • 10. Concurrency Control by Locking
    • Target resources
      • Database
      • Table
      • Block
      • Record
    • Locking algorithm
      • Shard/exclusive lock
      • Intention lock for fine granularity
  • 11. Shared/Exclusive Lock
    • S: shared lock for read
    • X: exclusive lock for write
    S Trn 1 Trn 2 Trn 3   X Trn 1 Trn 2 Trn 3    
  • 12. Intention Lock O O O _ _ _ _ _ _ _ O _ O _ O O IS IX S X IS IX S X http://dev.mysql.com/doc/refman/5.5/en/innodb-lock-modes.html IX IX IS X S
  • 13. Logging with Redo Log Hector 2010 T 1: Read(A,t); t t  2; write (A,t); Read(B,t); t t  2; write (B,t); Output(A); Output(B) A: 8 B: 8 A: 8 B: 8 memory DB LOG <T1, end> 16 16 <T1, start> <T1, A, 16> <T1, B, 16> <T1, commit> output 16 16
  • 14. Buffer Cache Management
    • Allowance of dirty cache
      • No: write through
      • Yes: write back
    • Eviction strategy
      • LRU: least recently used
    • Prefetch
      • Sequential
  • 15. Data Structures Dictionary Table Index … Log Log Log Table Index Statistics
  • 16. Inside Data Block R3 R4 R1 R2 Hector 2010 Header Free space
  • 17. Structures for Index Hash Function Tree Hash
  • 18. B+tree Example Hector 2010 Root 100 120 150 180 30 3 5 11 30 35 100 101 110 120 130 150 156 179 180 200
  • 19. Hash Example Hector 2010 INSERT: h(a) = 1 h(b) = 2 h(c) = 1 h(d) = 0 0 1 2 3 h(e) = 1 d a c b e
  • 20. Tree vs Hash for Indexing
    • Tree
      • O(log N) for single record retrieval
      • Efficient range scan is available
    • Hash
      • O(1) for single record retrieval
      • Range scan is not supported
  • 21. Storage Hard Disk Drive Solid State Drive RAID Storage Storage Unit Controller Cache SCSI Protocol Stack/HBA Drivers Buffer Cache Manager File System Logical Unit/Software RAID Manager OS Functionalities for Storage IO Controller Cache Controller Cache
  • 22. Hard Disk Drive Track Sector Disk Platter Lseek size lseek size Small lseek Large lseek (smoothed) IO Response IO Response
  • 23. Summary
    • DBMS
      • Query Processor
      • Storage Engine
    • Storage
  • 24. References
    • Database System Implementation Lecture notes at Stanford University.
      • http://infolab.stanford.edu/~ullman/dbsi.html
    • MySQL InnoDB Internal
      • http://www.innodb.com/wp/wp-content/uploads/2009/05/innodb-file-formats-and-source-code-structure.pdf
    • MySQL Reference Manual
      • http://dev.mysql.com/doc/
  • 25. For Further Study
    • Fundamentals of Database systems
      • http://www.amazon.com/Fundamentals-Database-Systems-Ramez-Elmasri/dp/0136086209
    • Books recommended by Leo’s Chronicle
      • http://leoclock.blogspot.com/2009/01/blog-post_07.html
  • 26. Fundamentals of Database Systems