Let us talk about Maria.. no no not Maria Sharapova, its new version of MyISAM engine for MySQL which is claimed to be crash safe and provides more concurrency. It aims at becoming fully transactional (ACID). Following are the features of Maria.
- ACID (Atomicity, Consistency, Isolation, Durability)
- Concurrent selects (via MVCC)
- Row locking
- Group commit
Frequently Asked Question (FAQ) about Maria.1. How does Maria 1.0 Compare to MyISAM ? Maria 1.0 is basically a crash-safe non transactional version of MyISAM. Maria supports all aspects of MyISAM, except as noted below. This includes external and internal check/repair/compressing of rows, different row formats, different index compress formats, maria_check etc. After a normal shutdown one can copy Maria files between servers.
Advantages of Maria (Compared to MyISAM)
- Data and indexes are crash safe.
- On a crash, changes will be rolled back to state of the start of a statement or a last LOCK TABLES commands.
- Maria can replay almost everything from the log. (Including create/drop/rename/truncate tables). Therefore, you make a backup of Maria by just copying the log. The things that can’t be replayed (yet) are:
- Batch INSERT into an empty table (This includes LOAD DATA INFILE, SELECT … INSERT and INSERT (many rows))
- ALTER TABLE. Note that .frm tables are NOT recreated!
- LOAD INDEX can skip index blocks for unwanted indexes
- Supports all MyISAM row formats + new PAGE format where data is stored in pages. (default size is 8K)
- When using PAGE format (default) row data is cached by page cache.
- Maria has unit tests of most parts
- Supports both crash-safe (soon to be transactional) and not transactional tables. (Non-transactional tables are not logged and rows uses less space): CREATE TABLE foo (…) TRANSACTIONAL=0|1 ENGINE=Maria
- PAGE is the only crash-safe/transactional row format.
- PAGE format should give a notable speed improvement on systems which have bad data caching. (For example windows).
Differences between Maria and MyISAM:
- Maria uses BIG (1G by default) log files.
- Maria has a log control file (maria_log_control) and log files ( maria_log.???????). The log files can be automatically purged when not needed or purged on demand (after backup).
- Maria uses 8K pages by default (MyISAM uses 1K). This makes Maria a bit faster when using keys of fixed size, but slower when using variable-length packed keys (until we add a directory to index pages)
Disadvantages of Maria (compared to MyISAM), that will be fixed soon
- Maria 1.0 has one writer or many readers. (MyISAM can have one inserter and many readers when using concurrent inserts).
- Maria doesn’t support INSERT DELAYED.
- Maria does not support multiple key caches.
Disadvantages of Maria (compared to MyISAM), that will be fixed in later releases
- Storage of very small rows.
- MERGE tables don’t support Maria (should be very easy to add later).
Differences that are not likely to be fixed.
- Maria data pages in block format have an overhead of 10 bytes/page and 5 bytes/row. Transaction and multiple concurrent-writer support will use an extra overhead of 7 bytes for new rows, 14 bytes for deleted rows and 0 bytes for old compacted rows.
- No external locking (MyISAM has external locking, but is not much used)
- Maria has one page size for both index and data (defined when Maria is used the first time). MyISAM supports different page sizes per index.
- Index number requires one extra byte per index page.
- Maria doesn’t support MySQL internal RAID (disabled in MyISAM too, it’s a deprecated feature)
- Minimum data file size for PAGE format is 16K (with 8K pages)
- Maria is compiled in by default and required to be ‘in use’ when mysqld is started.
- Internal on-disk tables are in Maria table format instead of MyISAM table format. This should speed up some GROUP BY and DISTINCT queries because Maria has better caching than MyISAM.
New options to CREATE TABLE:
- TRANSACTIONAL= 0 | 1 ; Transactional means crash-safe for Maria <>
- PAGE_CHECKSUM= 0 | 1 ; If index and data should use page checksums for extra safety.
- TABLE_CHECKSUM= 0 | 1 ; Same as CHECKSUM in MySQL 5.1
- ROW_FORMAT=PAGE ; The new cacheable row format for Maria tables. Default row format for Maria tables and only row format that can be used if TRANSACTIONAL=1. To emulate MyISAM, use ROW_FORMAT=FIXED or ROW_FORMAT=DYNAMIC
- CHECKSUM TABLE now ignores values in NULL fields. This makes CHECKSUM TABLE faster and fixes some cases where same table definition could give different checksum values depending on row format. The disadvantage is that the value is now different compared to other MySQL installations. The new checksum calculation is fixed for all table engines that uses the default way to calculate and MyISAM which does the calculation internally. Note: Old MyISAM tables with internal checksum will return the same checksum as before. To fix them to calculate according to new rules you have to do an ALTER TABLE. You can use the old ways to calculate checksums by using the option –old to mysqld or set the system variable ‘@@old’ to 1 when you do CHECKSUM TABLE … EXTENDED;
- At startup Maria will check the Maria logs and automatically recover the tables from last checkpoint if mysqld was not taken down correctly.
- There are some improvements to DBUG code to make its execution faster when debug is compiled in but not used.
- To create a new, ACID and multi-version concurrency Control (MVCC), transactional storage engine that can function as the default non-transactional an the default transactional storage engine for MySQL.
- To be a MyISAM replacement. This is possible because Maria can also be run in non-transactional mode, supports all row formats as MyISAM, and supports or will support all major features of MyISAM.
- Maria to be standard part of MySQL 6.X
Note that the rows are not cached in the page cache for FIXED or DYNAMIC format. If you want to have the data cached (something MyISAM doesn’t support) you should use ROW_FORMAT=PAGE:Code language: SQL (Structured Query Language) (sql)
CREATE TABLE t1 (a int) ROW_FORMAT=FIXED TRANSACTIONAL=0 PAGE_CHECKSUM=0; CREATE TABLE t2 (a int) ROW_FORMAT=DYNAMIC TRANSACTIONAL=0 PAGE_CHECKSUM=0; SHOW CREATE TABLE t1; SHOW CREATE TABLE t2;
You can use PAGE_CHECKSUM=1 also for non-transactional tables; This puts a page checksums on all index pages. It also puts a checksum on data pages if you use ROW_FORMAT=PAGE.Code language: SQL (Structured Query Language) (sql)
CREATE TABLE t3 (a int) ROW_FORMAT=PAGE TRANSACTIONAL=0 PAGE_CHECKSUM=0; SHOW CREATE TABLE t1;