0% found this document useful (0 votes)
6 views

My sql architecture

The document discusses the architecture of MySQL, the world's most popular open-source database system, highlighting its client-server model and major components such as the application layer, MySQL server layer, and storage engine layer. It details the functionalities of various storage engines like MyISAM, InnoDB, and others, along with their advantages and disadvantages. The article serves as a guide for novice database administrators and developers interested in understanding MySQL's internal architecture.

Uploaded by

anitarooge
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

My sql architecture

The document discusses the architecture of MySQL, the world's most popular open-source database system, highlighting its client-server model and major components such as the application layer, MySQL server layer, and storage engine layer. It details the functionalities of various storage engines like MyISAM, InnoDB, and others, along with their advantages and disadvantages. The article serves as a guide for novice database administrators and developers interested in understanding MySQL's internal architecture.

Uploaded by

anitarooge
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

The architecture of the world’s most popular open source database system is very

important for the Information Technology people. There are many reasons for MySQL’s
popularity around the world, but one of the main reasons is its architecture, while there
are many big players such as Oracle, Microsoft SQL and DB2, MySQL’s architecture
makes it as unique and preferred choice for most of the developers. In this article, we
are going to discuss about of the internal architecture of the MySQL relational database
management system. The article is for novice database administrators, database
developers, software developers and those who are interested to work with MySQL
database.

Major components:
The MySQL architecture describes how the different components of a MySQL system
relate to one another. The MySQL architecture is basically a client – server system.
MySQL database server is the server and the applications which are connecting to
MySQL database server are clients. The MySQL architecture contains the following
major components.

MySQL ARCHITECTURE

Application Layer:
This layer is the top most layers in MySQL architecture; you can see this same layer in
many of the client – server architecture. This layer includes some of the services which
are common to most of the client – server applications, some of the services are given
below:
o Connection Handling.
o Authentication.
o Security.
Connection Handling:
When a client connects to server, the client gets its own thread for its connection. All
the queries from that client executed within that specified thread. The thread is cached
by the server, so they don’t need to created and destroyed for each new connection.

Authentication:
Whenever a client connects to a MySQL server, the server performs the authentication
in the server side. The authentication is based on the username, host of the client and
password of the client user.

Example:
root@localhostroot : Username of the client.
localhost : host name, from where it is originated.

Security:
After the client gets connected successfully to MySQL server, the server will check whether that
particular client has the privileges to issue certain queries against MySQL server.
Example:
mysql> show privileges \G
*************************** 1. row ***************************
Privilege: Alter
Context: Tables
Comment: To alter the table
*************************** 2. row ***************************
Privilege: Alter routine
Context: Functions,Procedures
Comment: To alter or drop stored functions/procedures

MySQL Server layer:


This layer takes care of all the logical functionalities of the MySQL relational database management
system. The brain of the MySQL server is resides in this layer. The logical layer of the MySQL is
divided into various sub components, which are given below:
o MySQL services and utilities.
o SQL Interface.
o SQL Parser.
o Optimizer.
o Caches & buffers.

MySQL services and utilities:


MySQL comparatively provides wide range of services and utilities. This is one of the main reasons
for the popularity of the MySQL. This layer provides the services and utilities for administration and
maintenance of MySQL system, some of them are mentioned below:
o Backup & recovery.
o Security.
o Replication.
o Cluster.
o Partitioning.
o Workbench.

SQL Interface:
Structured Query Language (SQL) is a query language, used to query MySQL server. It is a tool
to interact between MySQL client user and server. Some of the SQL interface components are given
below.
o Data Manipulation Language (DML).
o Data Definition Language (DDL).
o Stored Procedures.
o Views.
o Triggers.

Parser:
MySQL parses queries to create an internal structure (the parse tree). The MySQL parser behaves
as a single pass compiler. As per the MySQL internals, the parser structure is given below.
o Lexical analysis (making words or tokens from a character stream) is
implemented at first stage, when parsing regular statements.
o Syntactic analysis (making “sentences”), semantic analysis (making sure
these sentences do make sense), and code generation (for compilers) – all
of them – are done at once, during the phase of code.

Optimizer:
After creating the internal parse tree, the MySQL applies a variety of optimization techniques. These
techniques may include, rewriting the query, order of scanning of tables and choosing the right
indexes to use. Actually you can ask the server to explain the various aspects of optimization.
Example:
EXPLAIN SELECT * FROM world.city;

Caches:
The MySQL cache (query cache) stores complete result sets for SELECT statements. Even before
parsing the query, the MySQL server consults the query cache. If any client issues a query that is
identical to one already in the in the cache, the server simply skip the parsing, optimization and even
execution, it just simply display the output from the cache.

Storage Engine Layer:


The pluggable storage engine feature makes the MySQL as unique and preferred choice for most of
the developers. This is the feature which makes the MySQL to reach an edge over the big player.
MySQL allows us to choose the variety storage engines for different situations and requirements.
We are going to discuss about the features of each storage engine in upcoming article, just the list of
supported storage engines are mentioned below.
o MyISAM.
o InnoDB.
o Federated.
o Mrg_MyISAM.
o Blackhole.
o CSV.
o Memory.
o Archive.
o Performance_schema.

MySQL provides this as a pluggable storage engines, various storage engines can be used at table
level. A database can contain the tables with the multiple storage engines.

MySQL table types/storage engines are essential features that can be used
effectively for maximizing the database's performance. It handles
create, read, and update operations for storing and managing the
information in a database. In this tutorial, we are going to understand
various storage engines or table types used in MySQL.

The following are various table types/storage engines supports in


MySQL:

o ISAM
o MyISAM
o MERGE
o InnoDB
o MEMORY (HEAP)
o ARCHIVE
o BDB
o CSV
o FEDERATED

We can use the below query that determines which table types/storage
engines our MySQL server supports.

1. mysql> SHOW ENGINES;


The Support column value indicates whether an engine can be used or not
in the current server. A value of YES, NO, or DEFAULT shows that table
type is available, not available, and available & currently set as the
default table type/storage engine.

It is essential to understand each table type's features in MySQL that enable


us to decide the most appropriate among them for our table that maximizes
the performance of our databases. Each table type in MySQL has its own
advantages and disadvantages. Let us learn each table type/storage engine
and its advantages and disadvantages for choosing which one to use among
them.

ISAM Table
It is abbreviated as Indexed Sequential Access Method. This table
type/storage engine has been deprecated and removed from MySQL version
5.x. MyISAM now replaces the functionalities of this table. The size of an
ISAM table is 4 GB, which requires expensive hardware. It is not portable.

MyISAM Table
It is an extension of the ISAM storage engine. The MyISAM table types are
optimized for compression and speed and can be easily
portable between system to system. Before version 5.5, if we do not specify
the table type during table creation, it was the default storage engine. From
version 5.x, InnoDB is used as the default table type/storage engine.

The MyISAM table size is dependent on the OS and can be up to 256 TB. It
can be compressed into read-only tables that save spaces in memory.
MyISAM table type can store 64 keys per table and contains 1024 bytes
maximum key length. The MyISAM tables work very fast, but they are not
transaction-safe.
Advantages of MyISAM

o If you are new, it will be best to start with MyISAM because it is simple to
design and create.
o It is faster than other storage engines in general conditions.
o It provides full-text indexing/searching.

Disadvantages of MyISAM

o MyISAM tables are not transactions-safe.


o It has poor data integrity and crash recovery.
o When we lock the entire table, in that case, MyISAM is slower than InnoDB.

InnoDB Table
The InnoDB tables in MySQL fully support transaction-safe storage
engine with ACID-compliant. It is the first table type that supports foreign
keys. The InnoDB tables also provide optimal performance. Its size can be up
to 64TB. InnoDB tables are also portable between systems to systems
similar to MyISAM. InnoDB tables can also be checked and repairs by MySQL
whenever necessary.

Advantages of InnoDB

o InnoDB provides optimal performance while processing a large amount of


data.
o InnoDB tables arrange our data on the disk based on the primary key.

Disadvantages of InnoDB

o InnoDB tables take more space on disk in comparison with MyISAM.

MERGE Table
MERGE table is also known as MRG_MyISAM. This table combines multiple
MyISAM tables with a similar structure (identical column and index
information with the same order) into a single table. This table uses indexes
of the component tables because it does not have its own indexes. When we
join multiple tables, it can also be used to speed up the database's
performance. We can perform only INSERT, SELECT, DELETE, and UPDATE
operations on the MERGE tables. If we use the DROP TABLE query in this
storage engine, MySQL only removed the MERGE specification, and the
underlying tables cannot be affected.

Advantages of MERGE

o The main advantage of this table is to remove the size limitation from
MyISAM tables.
o It performs more efficient searches and repairs.
o It manages the set of log tables easily.

Disadvantages of MERGE

o MySQL allows us to use only identical (similar structure) MyISAM tables for
the MERGE table.
o It cannot support all MyISAM features, such as we cannot create FULLTEXT
indexes on MERGE tables.
o It reads indexes slower.

Memory Table
The memory table type/storage engine creates tables, which will be
stored in our memory. It is also known as HEAP before MySQL version 4.1.
This table type is faster than MyISAM because it uses hash indexes that
retrieve results faster. We already know that data stored in memory can be
crashed due to power issues or hardware failure. Therefore, we can only use
this table as temporary work areas or read-only caches for data pulled from
other tables. Hence, the memory/heap tables will be lost whenever the
MySQL server halts or restarts. The memory/heap table's data life depends
on the uptime of the database server.

Advantages of Memory

The main advantage of this table type is its speed, which is very fast. It is
because it uses hash indexing that retrieves results faster.

Disadvantages of Memory

It is not a good idea to use the MEMORY storage for the long term because
the data would be lost easily as soon as the power failure or hardware crash.
CSV Table
The CSV table type/storage engine stores data in comma-separated values in
a file. It provides a convenient way to migrate data into many different
software packages, such as spreadsheet software. This table type is not as
good as a general database engine; however, it enables us to exchange our
data most effectively and easily. In addition, it will scan the whole table
during the read operation.

Advantages of CSV

This table type/storage engine is advantageous when we need to export


complex data from one application to a CSV file and then import it into
another application.

Disadvantages of CSV

o It is not good to store a large volume of data or larger data types like BLOB,
although such types are supported.
o It makes data retrieval slow because there is no indexing.

FEDERATED Table
The FEDERATED table type/storage engine supports MySQL from version
5.03 that allows access data from a remote MySQL server without using the
cluster/replication technology. The federated storage engine located in local
storage does not store any data. If we will query data from a federated table
stored in local memory, MySQL automatically pulled data from the remote
federated tables. It is to note that it's a way for a server, not for a client, for
accessing a remote database. It is an effective way to combine data from
more than one host or copy data from remote databases into local tables
without using the data import and export method.

ARCHIVE Table
This table type/storage engine allows us to store a large volume of
data in a compressed format to save disk space and cannot be
modified. Thus, it is the perfect storage engine to store log data that is no
longer in active use, such as the old invoice or sales data. It compresses the
data during the insertion and can decompress it using the Zlib library.

The archive tables only support INSERT and SELECT queries. It does not
support most of the data types, such as index data type, without which we
need to scan a full table for reading rows.
Since it stored the information in a compressed format and if we want to
read the table, we first need to decompress the information. This process will
take time to perform complex searches and retrievals. Therefore, if we have
to perform a large number of queries in these tables, it is beneficial to use
another table such as MyISAM.

BDB Table
BDB stands for the Berkeley DB engine, which is developed
by SleepyCat software. It is similar to InnoDB in the transaction-safe. It is
based on the hash storage mechanism that makes the recovery of
information very quickly. It supports page-level locking, but the data file is
not portable.

You might also like