SlideShare une entreprise Scribd logo
1  sur  16
MySQL
Dept. of Computing Science, University of Aberdeen 2
In this lecture you will learn
• The main subsystems in MySQL
architecture
• The different storage engines or table
types in MySQL
• How you can define the storage engine
or table type to be used for your tables
• How you can improve the performance
of your queries
Dept. of Computing Science, University of Aberdeen 3
Introduction
• MySQL is an open source RDBMS
• Main Features
– Server-client architecture
– Available for a variety of platforms including Windows and
Linux
– Multiple storage engines
• Users/applications can select the storage engine for their
database
– Based on their requirements
• Can even mix and match different engines within the same
database
– Supports ANSI SQL
– Version 5.0 is the current stable release
– Version 5.0 supports certain spatial data types
Dept. of Computing Science, University of Aberdeen 4
MySQL Architecture
• Primary subsystems
– The Query Engine
– The Storage Manager
– The Buffer Manager
– The Transaction Manager
– The Recovery Manager
• Support components
– The Process Manager
• Connectivity functionality
– Function Libraries
• General functions used by all the subsystems
Dept. of Computing Science, University of Aberdeen 5
MySQL Architecture
Operating System
Storage ManagerInnoDB
(transactional)
MyISAM
(default)
Memory
(In-memory)
NDB
(Clustered)
Buffer Manager Transaction Manager
Recovery ManagerQuery Engine
Dept. of Computing Science, University of Aberdeen 6
Query Engine
• Three components
– Syntax parser
• Translates SQL query to an internal form, RAT
• Correctness of the syntax is established
• User privileges are used to verify if the query makes legal
references to tables (or fields)
– Query optimizer
• Selects the most efficient query execution plan
– Execution component
• Executes the query by making calls to other modules
Dept. of Computing Science, University of Aberdeen 7
The Storage Manager
• Responsible for file organization and indexing
• Interfaces with the OS to write to disk all of the data, such as
– User tables, indexes and logs
• The component that makes MySQL special by
– Offering different types of storage engines (or table types)
• Advantages of multiple storage engines
– When new engines are added to the server, the server architecture
allows supporting older file formats
– Changes to storage engines do not cause changes elsewhere in
MySQL
– Different users/applications have a choice in the storage engine
used
– Easier to introduce new storage media (compact flash) which may
require different approach
Dept. of Computing Science, University of Aberdeen 8
Storage Engines
• MyISAM (default)
– extensions to the traditional ISAM
– No support for transactions
– No referential integrity
• InnoDB (Transactional)
– Supports transactions with ‘ACID’ properties
– Supports referential integrity
• Memory (In-memory)
– Tables of this type are stored in RAM; therefore fast
– But data will be lost in the event of a crash
• NDB (Clustered) – advanced storage method - not
here
• You will be using mostly MyISAM or InnoDB
Dept. of Computing Science, University of Aberdeen 9
Buffer Manager
• Manages memory management issues
– Between query engine and memory manager
• Maintains Query Cache which
– Stores the result sets of queries
– Repeated queries are answered directly from query cache
• New records are cached in before being written to
disk
• Query cache is unique to MySQL
• Is responsible for enhanced response times
– Studies show that MySQL works as fast as Oracle and SQL
server (Microsoft’s RDBMS server)
Dept. of Computing Science, University of Aberdeen 10
Recovery Manager
• Performs data recovery in the event of
loss of data
• Different for different storage engines
(or table types)
• InnoDB table provides recovery
management
• MyISAM table provides fixes to data
inconsistencies due to server outage
Dept. of Computing Science, University of Aberdeen 11
Transaction Management
• Performs locking and transaction management
• Different for different storage engines (or
table types)
• InnoDB table supports
– transaction management where transactions obey
‘ACID’ requirements
– row and table level locking
– All isolation levels
• MyISAM table supports
– Table level locking
Dept. of Computing Science, University of Aberdeen 12
Specifying the table type
• When you create a table you can specify the table type (storage
engine) for that table
• For example
CREATE TABLE test (id int(5) Primary Key, name varchar(25)) TYPE =
InnoDB;
• You can alter the type of an existing table to a different type
• For example
ALTER TABLE test TYPE = MyISAM;
• A single MySQL database can have tables of different types
• If you don’t require transactions, it is best to use MyISAM
• You can use SHOW TABLE STATUS to display information
about a table
• For example to display information about table called test
SHOW TABLE STATUS like ‘test’ G
Dept. of Computing Science, University of Aberdeen 13
Performance related issues
• MySQL allows users to ask for information about how their
select queries are processed using EXPLAIN
• EXPLAIN is the command to be added before your select
statement
• For example
mysql> explain select * from client where ClientNo='CR74';
+--------+------+---------------+------+---------+------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+------+---------+------+------+-------------+
| client | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
+--------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
Please note that the ‘possible_keys’ field is NULL – which means no index
defined
Please note that the ‘rows’ field is 4 – which means 4 rows (which is all the
rows client table has) which requires examination
Dept. of Computing Science, University of Aberdeen 14
Example continued
• Now add the index to the client table
mysql> alter table client add index(ClientNo);
Query OK, 4 rows affected (0.05 sec)
Records: 4 Duplicates: 0 Warnings: 0
• Now rerun the previous select query asking for explanation
mysql> explain select * from client where ClientNo='CR74';
+--------+------+---------------+----------+---------+-------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+----------+---------+-------+------+-------------+
| client | ref | ClientNo | ClientNo | 6 | const | 1 | Using where |
+--------+------+---------------+----------+---------+-------+------+-------------+
1 row in set (0.00 sec)
•Please note that now only one row needs to be examined and
the query therefore runs faster
•Please also note that this table now has an index
Dept. of Computing Science, University of Aberdeen 15
Further performance
enhancements
• You can improve the performance of your query further by
defining smaller indexes
• In the previous example ClientNo is used as the index
– it is five characters long
– therefore defining only part of the clientNo as the index may not
make much difference
• When longer fields are used as indexes
– It helps to define the index on part of the field (ref: slide 16)
• Query Optimizer in MySQL inspects all the indexes before
selecting one for use in query processing
• You can help MySQL by running the following statement to help
in the process of selecting the correct index
ANALYZE TABLE client;
• You can also instruct MySQL to reclaim space lost due to
deletion of records (holes)
OPTIMIZE TABLE client;
Dept. of Computing Science, University of Aberdeen 16
Example showing the use of
shorter indexes
mysql> explain select * from client where Lname = 'Ritchie';
+--------+------+---------------+------+---------+------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+------+---------+------+------+-------------+
| client | ALL | NULL | NULL | NULL | NULL | 4 | Using where |
+--------+------+---------------+------+---------+------+------+-------------+
1 row in set (0.00 sec)
mysql> alter table client add index(Lname(3));
Query OK, 4 rows affected (0.03 sec)
Records: 4 Duplicates: 0 Warnings: 0
mysql> explain select * from client where Lname = 'Rit';
+--------+------+---------------+-------+---------+-------+------+-------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+--------+------+---------------+-------+---------+-------+------+-------------+
| client | ref | Lname | Lname | 4 | const | 1 | Using where |
+--------+------+---------------+-------+---------+-------+------+-------------+
1 row in set (0.00 sec)

Contenu connexe

Tendances

MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883Kwaye Kant
 
MonetDB :column-store approach in database
MonetDB :column-store approach in databaseMonetDB :column-store approach in database
MonetDB :column-store approach in databaseNikhil Patteri
 
MySQL and bioinformatics
MySQL and bioinformatics MySQL and bioinformatics
MySQL and bioinformatics Arindam Ghosh
 
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruIBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruRavikumar Nandigam
 
Learn Database Design with MySQL - Chapter 3 - My sql storage engines
Learn Database Design with MySQL - Chapter 3 - My sql storage enginesLearn Database Design with MySQL - Chapter 3 - My sql storage engines
Learn Database Design with MySQL - Chapter 3 - My sql storage enginesEduonix Learning Solutions
 
MySQL 简要介绍
MySQL 简要介绍MySQL 简要介绍
MySQL 简要介绍YUCHENG HU
 
IBM DB2 LUW/UDB DBA Training by www.etraining.guru
IBM DB2 LUW/UDB DBA Training by www.etraining.guruIBM DB2 LUW/UDB DBA Training by www.etraining.guru
IBM DB2 LUW/UDB DBA Training by www.etraining.guruRavikumar Nandigam
 
Dd and atomic ddl pl17 dublin
Dd and atomic ddl pl17 dublinDd and atomic ddl pl17 dublin
Dd and atomic ddl pl17 dublinStåle Deraas
 

Tendances (13)

MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883MySQL DBA OCP 1Z0-883
MySQL DBA OCP 1Z0-883
 
MySQL database
MySQL databaseMySQL database
MySQL database
 
MonetDB :column-store approach in database
MonetDB :column-store approach in databaseMonetDB :column-store approach in database
MonetDB :column-store approach in database
 
MySQL DBA
MySQL DBAMySQL DBA
MySQL DBA
 
Mysql database
Mysql databaseMysql database
Mysql database
 
MySQL and bioinformatics
MySQL and bioinformatics MySQL and bioinformatics
MySQL and bioinformatics
 
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guruIBM DB2 LUW UDB DBA Online Training by Etraining.guru
IBM DB2 LUW UDB DBA Online Training by Etraining.guru
 
MySQL vs MonetDB Bencharmarks
MySQL vs MonetDB BencharmarksMySQL vs MonetDB Bencharmarks
MySQL vs MonetDB Bencharmarks
 
MySQL vs. MonetDB
MySQL vs. MonetDBMySQL vs. MonetDB
MySQL vs. MonetDB
 
Learn Database Design with MySQL - Chapter 3 - My sql storage engines
Learn Database Design with MySQL - Chapter 3 - My sql storage enginesLearn Database Design with MySQL - Chapter 3 - My sql storage engines
Learn Database Design with MySQL - Chapter 3 - My sql storage engines
 
MySQL 简要介绍
MySQL 简要介绍MySQL 简要介绍
MySQL 简要介绍
 
IBM DB2 LUW/UDB DBA Training by www.etraining.guru
IBM DB2 LUW/UDB DBA Training by www.etraining.guruIBM DB2 LUW/UDB DBA Training by www.etraining.guru
IBM DB2 LUW/UDB DBA Training by www.etraining.guru
 
Dd and atomic ddl pl17 dublin
Dd and atomic ddl pl17 dublinDd and atomic ddl pl17 dublin
Dd and atomic ddl pl17 dublin
 

En vedette

Connections II Overview - August 2013 Webinar
Connections II Overview - August 2013 WebinarConnections II Overview - August 2013 Webinar
Connections II Overview - August 2013 WebinarUSGSA
 
Project Bramenvla
Project BramenvlaProject Bramenvla
Project Bramenvlawoosklda
 
Htc one deals ppt 2
Htc one deals ppt 2Htc one deals ppt 2
Htc one deals ppt 2oddysmith
 

En vedette (7)

Glenwood
GlenwoodGlenwood
Glenwood
 
Kortom
KortomKortom
Kortom
 
Connections II Overview - August 2013 Webinar
Connections II Overview - August 2013 WebinarConnections II Overview - August 2013 Webinar
Connections II Overview - August 2013 Webinar
 
Project Bramenvla
Project BramenvlaProject Bramenvla
Project Bramenvla
 
Orcid-nasig-presentation
Orcid-nasig-presentationOrcid-nasig-presentation
Orcid-nasig-presentation
 
Kad English Magazine Issue1
Kad English Magazine Issue1Kad English Magazine Issue1
Kad English Magazine Issue1
 
Htc one deals ppt 2
Htc one deals ppt 2Htc one deals ppt 2
Htc one deals ppt 2
 

Similaire à My sql

Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsNelson Calero
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for BestcomIvan Tu
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day trainingIvan Tu
 
Microsoft sql server database administration
Microsoft sql server database administrationMicrosoft sql server database administration
Microsoft sql server database administrationRahul Singh
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMahesh Salaria
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytWrushabhShirsat3
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerIDERA Software
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStoreMariaDB plc
 
Database Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementDatabase Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementOllieShoresna
 
My sql technical reference manual
My sql technical reference manualMy sql technical reference manual
My sql technical reference manualMir Majid
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)Gustavo Rene Antunez
 
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonMariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonIvan Zoratti
 
Designing, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons LearnedDesigning, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons LearnedDenny Lee
 
Data Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlData Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlHAFIZ Islam
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Antonios Chatzipavlis
 

Similaire à My sql (20)

Collaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAsCollaborate 2012 - Administering MySQL for Oracle DBAs
Collaborate 2012 - Administering MySQL for Oracle DBAs
 
Fudcon talk.ppt
Fudcon talk.pptFudcon talk.ppt
Fudcon talk.ppt
 
My sql introduction for Bestcom
My sql introduction for BestcomMy sql introduction for Bestcom
My sql introduction for Bestcom
 
My S Q L Introduction for 1 day training
My S Q L  Introduction for 1 day trainingMy S Q L  Introduction for 1 day training
My S Q L Introduction for 1 day training
 
Microsoft sql server database administration
Microsoft sql server database administrationMicrosoft sql server database administration
Microsoft sql server database administration
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source Database
 
unit-ii.pptx
unit-ii.pptxunit-ii.pptx
unit-ii.pptx
 
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfytxjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
xjtrutdctrd5454drxxresersestryugyufy6rythgfytfyt
 
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL ServerGeek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
Geek Sync I Need for Speed: In-Memory Databases in Oracle and SQL Server
 
Sql Server2008
Sql Server2008Sql Server2008
Sql Server2008
 
MariaDB ColumnStore
MariaDB ColumnStoreMariaDB ColumnStore
MariaDB ColumnStore
 
Database Systems Design, Implementation, and Management
Database Systems Design, Implementation, and ManagementDatabase Systems Design, Implementation, and Management
Database Systems Design, Implementation, and Management
 
My sql technical reference manual
My sql technical reference manualMy sql technical reference manual
My sql technical reference manual
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)My First 100 days with a MySQL DBMS (WP)
My First 100 days with a MySQL DBMS (WP)
 
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live LondonMariaDB 10 Tutorial - 13.11.11 - Percona Live London
MariaDB 10 Tutorial - 13.11.11 - Percona Live London
 
Designing, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons LearnedDesigning, Building, and Maintaining Large Cubes using Lessons Learned
Designing, Building, and Maintaining Large Cubes using Lessons Learned
 
Nosql data models
Nosql data modelsNosql data models
Nosql data models
 
Data Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlData Warehouse Logical Design using Mysql
Data Warehouse Logical Design using Mysql
 
Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019Modernizing your database with SQL Server 2019
Modernizing your database with SQL Server 2019
 

Dernier

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 

Dernier (20)

Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 

My sql

  • 2. Dept. of Computing Science, University of Aberdeen 2 In this lecture you will learn • The main subsystems in MySQL architecture • The different storage engines or table types in MySQL • How you can define the storage engine or table type to be used for your tables • How you can improve the performance of your queries
  • 3. Dept. of Computing Science, University of Aberdeen 3 Introduction • MySQL is an open source RDBMS • Main Features – Server-client architecture – Available for a variety of platforms including Windows and Linux – Multiple storage engines • Users/applications can select the storage engine for their database – Based on their requirements • Can even mix and match different engines within the same database – Supports ANSI SQL – Version 5.0 is the current stable release – Version 5.0 supports certain spatial data types
  • 4. Dept. of Computing Science, University of Aberdeen 4 MySQL Architecture • Primary subsystems – The Query Engine – The Storage Manager – The Buffer Manager – The Transaction Manager – The Recovery Manager • Support components – The Process Manager • Connectivity functionality – Function Libraries • General functions used by all the subsystems
  • 5. Dept. of Computing Science, University of Aberdeen 5 MySQL Architecture Operating System Storage ManagerInnoDB (transactional) MyISAM (default) Memory (In-memory) NDB (Clustered) Buffer Manager Transaction Manager Recovery ManagerQuery Engine
  • 6. Dept. of Computing Science, University of Aberdeen 6 Query Engine • Three components – Syntax parser • Translates SQL query to an internal form, RAT • Correctness of the syntax is established • User privileges are used to verify if the query makes legal references to tables (or fields) – Query optimizer • Selects the most efficient query execution plan – Execution component • Executes the query by making calls to other modules
  • 7. Dept. of Computing Science, University of Aberdeen 7 The Storage Manager • Responsible for file organization and indexing • Interfaces with the OS to write to disk all of the data, such as – User tables, indexes and logs • The component that makes MySQL special by – Offering different types of storage engines (or table types) • Advantages of multiple storage engines – When new engines are added to the server, the server architecture allows supporting older file formats – Changes to storage engines do not cause changes elsewhere in MySQL – Different users/applications have a choice in the storage engine used – Easier to introduce new storage media (compact flash) which may require different approach
  • 8. Dept. of Computing Science, University of Aberdeen 8 Storage Engines • MyISAM (default) – extensions to the traditional ISAM – No support for transactions – No referential integrity • InnoDB (Transactional) – Supports transactions with ‘ACID’ properties – Supports referential integrity • Memory (In-memory) – Tables of this type are stored in RAM; therefore fast – But data will be lost in the event of a crash • NDB (Clustered) – advanced storage method - not here • You will be using mostly MyISAM or InnoDB
  • 9. Dept. of Computing Science, University of Aberdeen 9 Buffer Manager • Manages memory management issues – Between query engine and memory manager • Maintains Query Cache which – Stores the result sets of queries – Repeated queries are answered directly from query cache • New records are cached in before being written to disk • Query cache is unique to MySQL • Is responsible for enhanced response times – Studies show that MySQL works as fast as Oracle and SQL server (Microsoft’s RDBMS server)
  • 10. Dept. of Computing Science, University of Aberdeen 10 Recovery Manager • Performs data recovery in the event of loss of data • Different for different storage engines (or table types) • InnoDB table provides recovery management • MyISAM table provides fixes to data inconsistencies due to server outage
  • 11. Dept. of Computing Science, University of Aberdeen 11 Transaction Management • Performs locking and transaction management • Different for different storage engines (or table types) • InnoDB table supports – transaction management where transactions obey ‘ACID’ requirements – row and table level locking – All isolation levels • MyISAM table supports – Table level locking
  • 12. Dept. of Computing Science, University of Aberdeen 12 Specifying the table type • When you create a table you can specify the table type (storage engine) for that table • For example CREATE TABLE test (id int(5) Primary Key, name varchar(25)) TYPE = InnoDB; • You can alter the type of an existing table to a different type • For example ALTER TABLE test TYPE = MyISAM; • A single MySQL database can have tables of different types • If you don’t require transactions, it is best to use MyISAM • You can use SHOW TABLE STATUS to display information about a table • For example to display information about table called test SHOW TABLE STATUS like ‘test’ G
  • 13. Dept. of Computing Science, University of Aberdeen 13 Performance related issues • MySQL allows users to ask for information about how their select queries are processed using EXPLAIN • EXPLAIN is the command to be added before your select statement • For example mysql> explain select * from client where ClientNo='CR74'; +--------+------+---------------+------+---------+------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +--------+------+---------------+------+---------+------+------+-------------+ | client | ALL | NULL | NULL | NULL | NULL | 4 | Using where | +--------+------+---------------+------+---------+------+------+-------------+ 1 row in set (0.00 sec) Please note that the ‘possible_keys’ field is NULL – which means no index defined Please note that the ‘rows’ field is 4 – which means 4 rows (which is all the rows client table has) which requires examination
  • 14. Dept. of Computing Science, University of Aberdeen 14 Example continued • Now add the index to the client table mysql> alter table client add index(ClientNo); Query OK, 4 rows affected (0.05 sec) Records: 4 Duplicates: 0 Warnings: 0 • Now rerun the previous select query asking for explanation mysql> explain select * from client where ClientNo='CR74'; +--------+------+---------------+----------+---------+-------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +--------+------+---------------+----------+---------+-------+------+-------------+ | client | ref | ClientNo | ClientNo | 6 | const | 1 | Using where | +--------+------+---------------+----------+---------+-------+------+-------------+ 1 row in set (0.00 sec) •Please note that now only one row needs to be examined and the query therefore runs faster •Please also note that this table now has an index
  • 15. Dept. of Computing Science, University of Aberdeen 15 Further performance enhancements • You can improve the performance of your query further by defining smaller indexes • In the previous example ClientNo is used as the index – it is five characters long – therefore defining only part of the clientNo as the index may not make much difference • When longer fields are used as indexes – It helps to define the index on part of the field (ref: slide 16) • Query Optimizer in MySQL inspects all the indexes before selecting one for use in query processing • You can help MySQL by running the following statement to help in the process of selecting the correct index ANALYZE TABLE client; • You can also instruct MySQL to reclaim space lost due to deletion of records (holes) OPTIMIZE TABLE client;
  • 16. Dept. of Computing Science, University of Aberdeen 16 Example showing the use of shorter indexes mysql> explain select * from client where Lname = 'Ritchie'; +--------+------+---------------+------+---------+------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +--------+------+---------------+------+---------+------+------+-------------+ | client | ALL | NULL | NULL | NULL | NULL | 4 | Using where | +--------+------+---------------+------+---------+------+------+-------------+ 1 row in set (0.00 sec) mysql> alter table client add index(Lname(3)); Query OK, 4 rows affected (0.03 sec) Records: 4 Duplicates: 0 Warnings: 0 mysql> explain select * from client where Lname = 'Rit'; +--------+------+---------------+-------+---------+-------+------+-------------+ | table | type | possible_keys | key | key_len | ref | rows | Extra | +--------+------+---------------+-------+---------+-------+------+-------------+ | client | ref | Lname | Lname | 4 | const | 1 | Using where | +--------+------+---------------+-------+---------+-------+------+-------------+ 1 row in set (0.00 sec)