Blogmark

The BLACKHOLE Storage Engine :: MySQL

via jbranchaud@gmail.com

https://dev.mysql.com/doc/refman/8.4/en/blackhole-storage-engine.html
MySQL

Reading through the ActiveRecord Migrations docs I came across an example demonstrating how to specify database-specific options like ENGINE=BLACKHOLE.

What is ENGINE+BLACKHOLE I wondered.

The BLACKHOLE storage engine acts as a “black hole” that accepts data but throws it away and does not store it. Retrievals always return an empty result

The provide the following code block to demonstrate the above:

mysql> CREATE TABLE test(i INT, c CHAR(10)) ENGINE = BLACKHOLE;
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO test VALUES(1,'record one'),(2,'record two');
Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

mysql> SELECT * FROM test;
Empty set (0.00 sec)

Reading further into the MySQL docs on this, there are all kinds of interesting behaviors and use cases:

Suppose that your application requires replica-side filtering rules, but transferring all binary log data to the replica first results in too much traffic. In such a case, it is possible to set up on the replication source server a “dummy” replica process whose default storage engine is BLACKHOLE