Your SlideShare is downloading. ×
MySQL Architectures And Concept(s)
Tuyen Vuong – Web Developer
vdt[dot]hutech[at]gmail[dot]com
MySQL Research
01-Aug-2013
MySQL Architecture | 01-Aug-2013 | 2
MySQL Architecture Overview
MySQL Architecture | 01-Aug-2013 | 3
MySQL Architecture Overview
APPLICATION LAYER
 Users and clients interacts with the ...
MySQL Architecture | 01-Aug-2013 | 4
MySQL Architecture Overview
LOGICAL LAYER
 The logical layer of MySQL architecture i...
MySQL Architecture | 01-Aug-2013 | 5
MySQL’s Logical Architecture
MySQL Architecture | 01-Aug-2013 | 6
MySQL’s Logical Architecture
Query Processor
• Query Processor further consists of th...
MySQL Architecture | 01-Aug-2013 | 7
MySQL’s Logical Architecture
Transaction Management
 It facilitates concurrent data ...
MySQL Architecture | 01-Aug-2013 | 8
MySQL’s Logical Architecture
Recovery Management
• Log Manager
 Logs every operation...
MySQL Architecture | 01-Aug-2013 | 9
MySQL’s Logical Architecture
Storage Management
• Storage Manager
 It acts like an i...
MySQL Architecture | 01-Aug-2013 | 10
MySQL’s - Concept
Concurrency Control
MySQL Architecture | 01-Aug-2013 | 11
MySQL’s - Concept
Lock Types and Lock Level
• Lock Types:
 Read Lock - The locked d...
MySQL Architecture | 01-Aug-2013 | 12
MySQL’s - Concept
Table Locks
 When a user holds a WRITE LOCK on a table, no
other ...
MySQL Architecture | 01-Aug-2013 | 13
MySQL’s - Concept
Row Locks
Why this needed?
 Main reason to use these locking is t...
MySQL Architecture | 01-Aug-2013 | 14
MySQL’s - Concept
Transactions
MySQL Architecture | 01-Aug-2013 | 15
MySQL’s - Concept
Transactions
• A transaction is a sequential group of database
man...
MySQL Architecture | 01-Aug-2013 | 16
MySQL’s - Concept
Properties of Transaction
•Atomicity: ensures that all operations ...
MySQL Architecture | 01-Aug-2013 | 17
MySQL’s - Concept
Transaction – COMMIT and ROLLBACK
•When a successful transaction i...
MySQL Architecture | 01-Aug-2013 | 18
MySQL’s - Concept
Isolation Levels
MySQL Architecture | 01-Aug-2013 | 19
MySQL’s - Concept
Deadlocks
MySQL Architecture | 01-Aug-2013 | 20
MySQL’s - Concept
Multiversion Concurrency Control
•MVCC (Multi Version Concurrency ...
MySQL Architecture | 01-Aug-2013 | 21
MySQL’s - Concept
MySQL’s Storage Engines
MySQL Architecture | 01-Aug-2013 | 22
MySQL’s - Concept
InnoDB
• InnoDB tables are transaction-safe (ACID compliant) stora...
MySQL Architecture | 01-Aug-2013 | 23
MySQL’s - Concept
MyISAM (1)
•MyISAM is the improved version of the original storage...
MySQL Architecture | 01-Aug-2013 | 24
MySQL’s - Concept
MyISAM (2)
•MyISAM table allows table level locking only.
•There a...
MySQL Architecture | 01-Aug-2013 | 25
MySQL’s - Architecture
Reference:
 Oreilly.High.Performance.MySQL.3rd.Edition
 MyS...
MySQL Architecture | 01-Aug-2013 | 26
Questions?
vdt.hutech@gmail.com
website: tuyenvuong.info
Upcoming SlideShare
Loading in...5
×

MySQL Atchitecture and Concepts

10,768

Published on

MySQL Atchitecture and Concepts

Published in: Technology, Education
1 Comment
27 Likes
Statistics
Notes
  • http://www.dbmanagement.info/Tutorials/MYSQL-PHP.htm MYSQL - PHP Video Training Tutorial DVDs (2 DVDs) Sale Price 19.97 More than 8 GB of Video files
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
10,768
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
1
Likes
27
Embeds 0
No embeds

No notes for slide

Transcript of "MySQL Atchitecture and Concepts"

  1. 1. MySQL Architectures And Concept(s) Tuyen Vuong – Web Developer vdt[dot]hutech[at]gmail[dot]com MySQL Research 01-Aug-2013
  2. 2. MySQL Architecture | 01-Aug-2013 | 2 MySQL Architecture Overview
  3. 3. MySQL Architecture | 01-Aug-2013 | 3 MySQL Architecture Overview APPLICATION LAYER  Users and clients interacts with the MySQL RDBMS.  There are three components in this layer. • Administrators • Clients • Query Users  Query users interact with MySQL RDBMS using “mysql”.  Administrators use various administrative interface and utilities like mysqladmin, isamchk etc.  Clients communicate with the MySQL RDBMS through various interfaces and utilities like the MySQL APIs.  “mysql”is actually a query interface. It’s a monitor that allows users to issue SQL statements and view the results.
  4. 4. MySQL Architecture | 01-Aug-2013 | 4 MySQL Architecture Overview LOGICAL LAYER  The logical layer of MySQL architecture is divided into various subsystems. • Query Processor. • Transaction Management. • Recovery Management. • Storage Management.  The above mentioned sub systems work together to process the requests issued to the MySQL database server.
  5. 5. MySQL Architecture | 01-Aug-2013 | 5 MySQL’s Logical Architecture
  6. 6. MySQL Architecture | 01-Aug-2013 | 6 MySQL’s Logical Architecture Query Processor • Query Processor further consists of the following systems.  Embedded DML Precompiler.  DDL Compiler.  Query Parser.  Query Preprocessor.  Security/Integration Manager.  Query Optimizer.  Execution Engine. • The output of one of the above component becomes the input for another. • Query processor layer is scalable and evolvable.
  7. 7. MySQL Architecture | 01-Aug-2013 | 7 MySQL’s Logical Architecture Transaction Management  It facilitates concurrent data access.  Provides locking facility.  Ensures multiple users/sessions access data simultaneously in a consistent way.  Prevents data corruption or data damage.  Lock Manager is the sub component name that handles locking.
  8. 8. MySQL Architecture | 01-Aug-2013 | 8 MySQL’s Logical Architecture Recovery Management • Log Manager  Logs every operation executed in the database.  Stores the operations logs as MySQL Commands.  Incase of SYSTEM crash executing these commands will bring back the database to its last stable state. • Recovery Manager  Responsible for recovering the database to its last stable state.  Uses the logs created by the log manager.
  9. 9. MySQL Architecture | 01-Aug-2013 | 9 MySQL’s Logical Architecture Storage Management • Storage Manager  It acts like an interface with the OS.  Its main job is efficient data write to the disk.  Storage Manager writes to disk all of the data in the user tables, indexes, logs as well as the internal system data. • Buffer Manager  It allocated memory resources.  It decides • Resource Manager  Accepts the requests from execution engine.  Requests the details from buffer manager.  It actually receives references of data with memory from buffer manager.  Returns this data to the upper layer.
  10. 10. MySQL Architecture | 01-Aug-2013 | 10 MySQL’s - Concept Concurrency Control
  11. 11. MySQL Architecture | 01-Aug-2013 | 11 MySQL’s - Concept Lock Types and Lock Level • Lock Types:  Read Lock - The locked data is reserved for read by the current session. Other sessions can read the locked data. But they can not write (update) the locked data. A read lock is also called a shared lock.  Write Lock - The locked data is reserved for write by the current session. Other sessions can not read and write the locked data. A write lock is also called an exclusive lock. • Lock Level:  Table Lock - The lock is set at the table level. All rows in the locked table are locked.  Row Lock - The lock is set at the row level. Some rows of a table are locked. But other rows are not locked.  Column Lock - The lock is set at the column level. Some columns of a row are locked. But other columns are not locked.
  12. 12. MySQL Architecture | 01-Aug-2013 | 12 MySQL’s - Concept Table Locks  When a user holds a WRITE LOCK on a table, no other users can read or write to that table  When a user holds a READ LOCK on a table, other users can also read or hold a READ LOCK, but no user can write or hold a WRITE LOCK on that table.  For example, if a user holds a WRITE LOCK on a table, no other user can issue a SELECT, UPDATE, INSERT, DELETE, or LOCK operation on that table.
  13. 13. MySQL Architecture | 01-Aug-2013 | 13 MySQL’s - Concept Row Locks Why this needed?  Main reason to use these locking is to handle the concurrent requests in proper way. This is the must required features when you are dealing with important data just like financial details. Pre Check Before Read Locking  First of your table’s storage engine must be set as InnoDB.  Your row locking query must executes after starting the transaction. Conclusion  It is better to use row locking mechanism if your database has high volume of insert and update statements. But few thing to keep in mind is that your table storage is set as InndoDB and your query must executes after starting the transaction.
  14. 14. MySQL Architecture | 01-Aug-2013 | 14 MySQL’s - Concept Transactions
  15. 15. MySQL Architecture | 01-Aug-2013 | 15 MySQL’s - Concept Transactions • A transaction is a sequential group of database manipulation operations, which is performed as if it were one single work unit. In other words, a transaction will never be complete unless each individual operation within the group is successful. If any operation within the transaction fails, the entire transaction will fail. • Practically you will club many SQL queries into a group and you will execute all of them together as a part of a transaction.
  16. 16. MySQL Architecture | 01-Aug-2013 | 16 MySQL’s - Concept Properties of Transaction •Atomicity: ensures that all operations within the work unit are completed successfully; otherwise, the transaction is aborted at the point of failure, and previous operations are rolled back to their former state. •Consistency: ensures that the database properly changes states upon a successfully committed transaction. •Isolation: enables transactions to operate independently of and transparent to each other. •Durability: ensures that the result or effect of a committed transaction persists in case of a system failure.
  17. 17. MySQL Architecture | 01-Aug-2013 | 17 MySQL’s - Concept Transaction – COMMIT and ROLLBACK •When a successful transaction is completed, the COMMIT command should be issued so that the changes to all involved tables will take effect. •If a failure occurs, a ROLLBACK command should be issued to return every table referenced in the transaction to its previous state. •If AUTOCOMMIT is set to 1 (the default), then each SQL statement (within a transaction or not) is considered a complete transaction, and committed by default when it finishes. When AUTOCOMMIT is set to 0, by issuing the SET AUTOCOMMIT=0 command, the subsequent series of statements acts like a transaction, and no activities are committed until an explicit COMMIT statement is issued.
  18. 18. MySQL Architecture | 01-Aug-2013 | 18 MySQL’s - Concept Isolation Levels
  19. 19. MySQL Architecture | 01-Aug-2013 | 19 MySQL’s - Concept Deadlocks
  20. 20. MySQL Architecture | 01-Aug-2013 | 20 MySQL’s - Concept Multiversion Concurrency Control •MVCC (Multi Version Concurrency Control) achieves both of concurrent update and isolation. •While execute update transaction, MVCC doesn’t overwrite but create new version. •First query (including SELECT query) in transaction uses newest version. Continued SELECT queries sees the version same to first query.
  21. 21. MySQL Architecture | 01-Aug-2013 | 21 MySQL’s - Concept MySQL’s Storage Engines
  22. 22. MySQL Architecture | 01-Aug-2013 | 22 MySQL’s - Concept InnoDB • InnoDB tables are transaction-safe (ACID compliant) storage engine that has commit, rollback, and crash recovery capabilities for data protection. • It supports row-level locking. • Foreign key referential-integrity constraint can be defined. • Table can extend to any size even beyond 2 GB and power loss recovery is fast. • The InnoDB stores user data in clustered indexes • This reduces I/O for common queries based on primary keys • InnoDB should be used for applications requiring the data integrity.
  23. 23. MySQL Architecture | 01-Aug-2013 | 23 MySQL’s - Concept MyISAM (1) •MyISAM is the improved version of the original storage engine of MySQL, ISAM •After MySQL 3.23, MyISAM replaced ISAM as the default storage engine. •The MyISAM engine is fast and thus, preferred for web and other application environments. •It is also used for data warehousing •MyISAM is not transaction-safe and supports 64 keys per table with maximum key length of 1024 bytes •The size of MyISAM table depends on the host operating system
  24. 24. MySQL Architecture | 01-Aug-2013 | 24 MySQL’s - Concept MyISAM (2) •MyISAM table allows table level locking only. •There are no limitations on data file transfer and the data files can be ported from system to system •The foreign key constraint cannot be defined •MyISAM is the only storage engine that supports Full-text search •It also supports one auto increment column per table •A high-byte-first pattern for saving numeric key values ensures faster indexing •It can be used where fulltext indexing is needed
  25. 25. MySQL Architecture | 01-Aug-2013 | 25 MySQL’s - Architecture Reference:  Oreilly.High.Performance.MySQL.3rd.Edition  MySQL Conceptual Architecture  http://www.mysql.com  Internet Bloggers
  26. 26. MySQL Architecture | 01-Aug-2013 | 26 Questions? vdt.hutech@gmail.com website: tuyenvuong.info

×