▣datahall
← back to gallery
client-serverC++est. 2009GPLv2

MariaDB

The community fork of MySQL: pluggable engines, MVCC InnoDB, and columnar storage for analytics.

MariaDB is a binary-compatible fork of MySQL that retains the MySQL client protocol and SQL dialect while replacing the storage engine layer with a more permissive set: InnoDB (default, MVCC), Aria (crash-safe MyISAM), ColumnStore (columnar, distributed), and Spider (sharding). The optimizer and parser are extended versions of MySQL’s.

Default engine
InnoDB (MVCC)
Pluggable storage
InnoDB, Aria, ColumnStore
Replication
async + semi-sync + Galera
Compatibility
MySQL wire protocol

InnoDB MVCC

InnoDB keeps up to 128 rollback segments of undo logs. Each row has a 6-byte transaction ID and a 7-byte roll pointer; old versions are read by following the chain.

Pluggable engines

A query plan can be served by any engine for any table. A single SELECT can join an InnoDB table to a ColumnStore table to a Spider-sharded remote table.

Galera cluster

A certification-based replication plugin that gives multi-master synchronous replication with conflict detection and zero data loss.

Optimistic row-level locking

Next-key locks and gap locks under REPEATABLE READ prevent phantoms; READ COMMITTED skips gap locks for higher throughput.

How InnoDB stores rows

A row in InnoDB lives on a 16 KiB page inside a tablespace (usually one file per table, configurable). Each row carries a 6-byte DB_TRX_ID and a 7-byte DB_ROLL_PTR. The roll pointer is the address of the undo log record that can reconstruct the previous version.

When a transaction updates a row, InnoDB writes a new row version in the clustered-index B-tree (which is the table) and inserts an undo record. Other transactions that started before the commit read the undo chain to find the version visible at their snapshot.

The query path

MariaDB ships a cost-based optimizer borrowed and extended from MySQL. SQL enters the parser, becomes a parse tree, then a resolved query block, then a plan. The optimizer applies join reordering, subquery unnesting, and condition pushdown before handing the plan to the executor.

The executor pulls rows through a Volcano-style iterator API. The same operator interface serves every storage engine, which is what makes the pluggable-engine model work.

              CREATE TABLE events (
  id BIGINT PRIMARY KEY AUTO_INCREMENT,
  payload JSON,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  INDEX (created_at)
) ENGINE=InnoDB ROW_FORMAT=DYNAMIC;
            

ColumnStore for analytics

ColumnStore is a separate engine that stores each column in its own file and skips irrelevant columns at read time. It runs across multiple servers and is the MariaDB answer to ClickHouse / Snowflake. You load data into a ColumnStore table, query it with the same SQL, and get column-pruned scans served by parallel workers.

Diagrams

page-microscopeInnoDB page anatomyclick nodes for description
innodb page · 16 KiBFIL header (38 B)space id · prev / next page · LSN · page typeinfimum + recordslinked listfree spacepage directorybinary-search slotstuple detail (full mode)DB_TRX_ID (6B)DB_ROLL_PTR (7B)non-null bitmapuser data

Each 16 KiB InnoDB page carries a FIL header, page directory slot array, infimum/supremum records, and user records with transaction IDs.

wal-timelineRedo log timelineclick nodes for description
timeredo logappend mtr at LSNundo logappend roll-pointer recorddoublewritepage write to safety copycommitfsync redo logcrash / power losson restart: replay WAL → consistent state

Log writes append to ib_logfile0/1; the log buffer flushes on commit. Crash recovery replays the redo log from the last checkpoint.

pipelineRead path: SQL -> optimizer -> storage engine -> InnoDB pageclick nodes for description
clientnetworkMySQL wire protocolparserexecutionparse tree, queryblockoptimizerexecutioncost-based planInnoDBindexclustered-indexB-treeundo chainconcurrencywalk for snapshotmode: read

MariaDB uses a pluggable storage engine layer; reads go through the optimizer into InnoDB, which serves pages from the buffer pool.

pipelineWrite path: SQL -> redo log -> doublewrite buffer -> tablespaceclick nodes for description
parserexecutionparse tree, query blockoptimizerexecutioncost-based planInnoDBindexwrite new row versionundo logdurabilityappend roll-pointerrecordredo log (LSN)durabilityfsync on commitdoublewrite bufferdurabilitycrash-safe page writesmode: write

Writes append to the redo log, then to the doublewrite buffer, then to the tablespace file. Crash recovery restores dirty pages from the doublewrite.

diagramMVCC snapshot timelineclick nodes for description
MVCC · Snapshot isolation timeline
t=0t=1t=2v1v2v3Tx ATx BTx C (sees v3)

InnoDB keeps undo chains; each transaction walks them to find the version visible at its snapshot.

diagramAsync + semi-sync replicationclick nodes for description
Replication · Async primary → replicas
Primarywrites + WALReplica Areads + cascadingReplica Breads onlyCascadingreads only

A primary streams binary logs to multiple replicas; Galera can extend this to multi-master.