MySQL Alternative Storage EnginesFor MySQL, MyISAM and InnoDB storage engines are very popular. Currently, we are mostly using InnoDB engines for high reliability and high performance. Apart from those engines, we also have some other alternative engines and they have some nice features in them. In this blog, I am going to explain some of those engines, which I have listed below. 

  • FEDERATED Storage Engine
  • Merge or MRG_MyISAM Engine
  • Blackhole Engine
  • CSV Engine

FEDERATED Storage Engine

Overview:

  • FEDERATED Storage Engine allows you to access the data remotely without replication and cluster technologies. 
  • Using the FEDERATED tables, you can scale your server load. Queries for the given table will be sent over the network to another MySQL instance. In this case, to scale the DB, you can use many MySQL instances without changing the application code.
  • FEDERATED tables are a security concern because you will need to save the host and user information in the table. It can be viewed using SHOW CREATE TABLE command.
  • Query optimization is limited and JOINs are slow.
  • Doing the bulk transaction may crash the local server.

By default, FEDERATED Storage Engine support is disabled. To enable it, you need to manually enable the variable “federated = ON” in the MySQL config file and restart the MySQL service. 

How Does it work?

  • FEDERATED tables need to be created on a local server and the remote table needs to be created on a remote server.
  • Make sure that you have the MySQL port and user access between the local and remote servers.
  • Remote tables can be created as MyISAM or InnoDB storage engines.
  • The FEDERATED table will not store any data. Data will be stored on the remote server.
  • Both local and remote servers should have the same columns and structure.
  • You can execute the query on both local or remote servers to modify or retrieve the data.

Example

I have two servers:

  • 172.28.128.16 (local server)
  • 172.28.128.17 (remote server)

On the local server, I am creating the FEDERATED table:

Syntax is:

On the remote server, I am creating the table with InnoDB engine:

As I mentioned earlier, the data will be physically stored on the remote server. FEDERATED tables will not store the data. From the below example, you can see the data file (.ibd) was created on the remote server and the local server just has the table structure file ( .frm ).

Local server:

Remote server:

Let’s do this experiment. On the local server, I am inserting the record. 

And on the remote server:

Now, I am going to update the data on a remote server.

At the local server:

It seems that you can execute the query on both local and remote servers. The FEDERATED Engine is mostly supported for data manipulation languages (INSERT/UPDATE/DELETE/TRUNCATE).

Merge or MRG_MyISAM Engine

Overview:

  • The collection of identical MyISAM tables can be used as a single table for better performance.
  • Only supported for MyISAM tables.
  • Merge tables will use more file descriptors. 
  • You can’t perform the FULL TEXT SEARCH using the merge tables.
  • Merge tables used extremely rare since partitions came around.

How Does it work?

  • It works only for the MyISAM tables.
  • The columns order, index, data types should be the same on all the tables.

Example

I have created two tables:

Inserting some data on both tables:

Now, creating the merge table:

Let’s query the merge table:

It seems, when I query the merge table, it merges both the tables (merge_1, merge_2) and displays the results. 

Physically, the MERGE table will not occupy any disk space. When querying the table, it will just merge the data from the configured tables and display the result.

Blackhole Engine

Overview: 

  • Blackhole Engine will accept the data from SQL. The accepted data will not be stored, whenever you are querying the data it will give the empty result.
  • Can be used for SQL syntax checking purposes. 
  • Can be used for the replication filter purpose. 
  • You have to be very careful when you use the table in a replication environment. Because the SQL will be logged in the binary log.

How Does it work?

Example

Creating the blackhole table:

Inserting and retrieving the data:

The data will be stored on the binary logs:

Syntax Checking Purposes

If you want to check any syntax of the SQL statements, you can directly execute them against the blackhole tables as it is not going to do anything with the data.

Replication Filter Purpose

Let’s consider that I have a source-replica setup. At the source, I have created the below table.

I don’t want to replicate this table to replica nodes. In this case, I just converted the table to BLACKHOLE engine on the replica node. 

At replica node:

Now, at source, I am inserting some records:

At replica, the data is not available. The data has been ignored as the table was converted to the blackhole engine.

CSV Engine

Overview: 

  • The CSV storage engine stores data in csv files. 
  • If you need the data into a CSV file, you can just copy the table physical file and use it. No need to export the data using the command SELECT INTO OUTFILE.
  • It will not support nullable columns.
  • The data will store comma-separated values.

Example

Creating the CSV table:

Inserting data:

Physically, you can see the data is stored as the .csv file. You can view the data from the file itself. 

As you see, MySQL alternative engines are having some good features. Based on my point of view, I would not suggest having them on production until finding a valid reason. But, it is still good to know about those engines and understand their features.


Percona Distribution for MySQL: An enterprise-grade solution for your most critical business applications.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
SimonMudd

No mention of rocksdb? Merge and federated engine sound like dead ends. Rocksdb sounds interesting as developed by and used by facebook and potentially allows considerable space savings, useful on large datasets. The blackhole engine does have a few handy use cases for odd situations.