MYSQL Table Types

MySQL provides various storage engines for its tables as below:

·        MyISAM

·        InnoDB

·        MERGE

·        MEMORY (HEAP)

·        ARCHIVE

·        CSV

·        FEDERATED

Each storage engine has its own advantages and disadvantages. It is crucial to understand each storage engine features and choose the most appropriate one for your tables to maximize the performance of the database. In the following sections, we will discuss about each storage engine and its features so that you can decide which one to use.

MyISAM

MyISAM extends the former ISAM storage engine. The MyISAM tables are optimized for compression and speed. MyISAM tables are also portable between platforms and operating systems.

The size of MyISAM table can be up to 256TB, which is huge. In addition, MyISAM tables can be compressed into read-only tables to save spaces. At startup, MySQL checks MyISAM tables for corruption and even repairs them in case of errors. The MyISAM tables are not transaction-safe.

Before MySQL version 5.5, MyISAM is the default storage engine when you create a table without specifying the storage engine explicitly. From version 5.5, MySQL uses InnoDB as the default storage engine.

Advantages of MyISAM

  • MyISAM is simple to design and create, if you are new then we would suggest you start with MyISAM.
  • MyISAM is faster than InnoDB in general conditions.
  • Full-text indexing / searching.
Disadvantages of MyISAM

  • MyISAM doesn’t support safe transactions.
  • Poor crash recovery and poor data integrity.
  • When the entire table is locked, at that time MyISAM is slower than InnoDB tables because they are frequently inserted and updated.

InnoDB

The InnoDB tables fully support ACID-compliant and transactions. They are also optimal for performance. InnoDB table supports foreign keys, commit, rollback, roll-and forward operations. The size of an InnoDB table can be up to 64TB.

Like MyISAM, the InnoDB tables are portable between different platforms and operating systems. MySQL also checks and repairs InnoDB tables, if necessary, at startup.

Advantages of InnoDB

  • When processing large data volumes InnoDB has the maximum performance.
  • For optimizing queries based on primary keys InnoDB tables arrange your data on the disk.
The disadvantage of InnoDB

  • Disadvantage of InnoDB in compare with MyISAM are it take more space on disk

MERGE

A MERGE table is a virtual table that combines multiple MyISAM tables that have similar structure into one table. The MERGE storage engine is also known as the MRG_MyISAM engine. The MERGE table does not have its own indexes; it uses indexes of the component tables instead.

Using MERGE table, you can speed up performance when joining multiple tables.

MySQL only allows you to perform SELECT, DELETE, UPDATE and INSERT operations on the MERGE tables. If you use DROP TABLE statement on a MERGE table, only MERGE specification is removed. The underlying tables will not be affected.

Advantages of MERGE

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

Disadvantages of MERGE

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

Memory

The memory tables are stored in memory and use hash indexes so that they are faster than MyISAM tables. The lifetime of the data of the memory tables depends on the up time of the database server. The memory storage engine is formerly known as HEAP.

 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.


Archive

The archive storage engine allows you to store a large number of records, which for archiving purpose, into a compressed format to save disk space. The archive storage engine compresses a record when it is inserted and decompress it using zlib library as it is read.

The archive tables only allow INSERT and SELECT statements. The ARCHIVE tables do not support indexes, so reading records requires a full table scanning.

CSV

The CSV storage engine stores data in comma-separated values (CSV) file format. A CSV table brings a convenient way to migrate data into non-SQL applications such as spreadsheet software.

CSV table does not support NULL data type and read operation requires a full table scan.

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

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

FEDERATED

The FEDERATED storage engine allows you to manage data from a remote MySQL server without using cluster or replication technology. The local federated table stores no data. When you query data from a local federated table, the data is pull automatically from the remote federated tables.

HEAP

  • Creates tables and those tables are stored in memory.
  • If your data crashes due to hardware or power issues, or if in any circumstances MYSQL server runs out of memory or restarts, memory table data is lost.
  • These tables work as temporary areas or read-only cache which is pulled from other tables.
  • It doesn’t support column with
    • Auto Increment
    • BOB (Binary Object)
    • Text character string

MERGE Storage Engine

  • Collection of identical MyISAM tables is the MERGE storage engine that can be used as a single table.
  • So it removes the limitation from MyISAM table.

Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post