The ARCHIVE Storage Engine – does it do what you expect?

Sometimes there is a need for keeping large amounts of old, rarely used data without investing too much on expensive storage. Very often such data doesn’t need to be updated anymore, or the intent is to leave it untouched. I sometimes wonder what I should really suggest to our Support customers.

For this purpose, the archive storage engine, added in MySQL 4.1.3, seems perfect as it provides excellent compression and the only DML statement it does allow is INSERT. However, does it really work as you would expect?

First of all, it has some serious limitations. Apart from lack of support for DELETE, REPLACE and UPDATE statements (which may be acceptable for some needs), another one is that it does not allow you to have indexes, although you can have an auto_increment column being either a unique or non-unique index. So usually straightforward converting your tables to archive engine will not be possible. See the list of features for reference.

But unfortunately, it does not always work as the manual says, within it’s described limitations. See the following very simple examples.

Problem I

Does the archive storage engine really ensure uniqueness for a primary or unique key?

That is really bad – a column being a primary key effectively allows duplicates! And another case exposing the same problem:

So even a simple optimize table command does break it completely. After we realize that such operation made our data bad, we won’t be able to easily go back to different engine without sacrificing uniqueness first:

There were already bug reports related to auto_increment feature being broken, but I have filed a new, more specific bug report about this problem.

Problem II

Are we always able to alter a table to use the archive storage engine, even if it is theoretically using supported table definition? Auto increment column issue again…

We have the same c table using archive. We can change it’s engine to something different:

But in some cases, we can’t set it back to archive!

There is an old bug report about that.

Problem III

And yet another weirdness around auto_increment values. It seems normal that databases allow us to insert explicit values into auto_increment columns, even lower then last inserted maximum, and all other engines – MyISAM, Memory and InnoDB do that:

But it’s not the case for Archive engine:

This undocumented behavior was reported here.


The archive storage engine provides a very good compression and is available in all MySQL variants out of the box. However it does have serious limitations as well as works unreliable and not as expected in some cases.

Related articles worth mentioning here:

In my next blog post, I am going to present simple research on (free) alternatives we do have that can replace the archive storage engine in terms of disk space effectiveness.

Share this post

Comments (4)

  • eRadical

    There are still use cases for ARCHIVE and I would hate it if it were to go away.

    I keep some analytics data and I change the storage engine of the “past” months from InnoDB into Archive (of course after altering the table). This saves me a lot of [expensive] disk space with the trade-off for speed when it comes to computing new stuff.

    January 7, 2014 at 9:57 am
  • Truls Bergskaug

    It is worth mention that replication of an ARCHIVE table with AUTOINCREMENT will most probably cause problems and headaches.

    January 8, 2014 at 4:22 am
  • Diego

    We are using ARCHIVE engine with range columns partitions using month and year columns, and the id column is populated by taken the autoincrement value from the table we want to archive.

    CREATE TABLE range_colums_partition (
    date datetime NOT NULL DEFAULT ‘0000-00-00 00:00:00’
    PARTITION 2014_07 VALUES LESS THAN (2014, 08),
    PARTITION 2014_08 VALUES LESS THAN (2014, 09),
    PARTITION 2014_09 VALUES LESS THAN (2014, 10),
    PARTITION 2014_10 VALUES LESS THAN (2014, 11),
    PARTITION 2014_11 VALUES LESS THAN (2014, 12),
    PARTITION 2014_12 VALUES LESS THAN (2015, 01),
    PARTITION 2015_01 VALUES LESS THAN (2015, 02),
    PARTITION 2015_02 VALUES LESS THAN (2015, 03),
    PARTITION 2015_03 VALUES LESS THAN (2015, 04),
    PARTITION 2015_04 VALUES LESS THAN (2015, 05),
    PARTITION 2015_05 VALUES LESS THAN (2015, 06),

    June 16, 2015 at 12:49 pm
  • Vael Victus

    I was hoping to see at least a small mention of the performance benefits of going with ARCHIVE.

    March 26, 2016 at 4:16 pm

Comments are closed.

Use Percona's Technical Forum to ask any follow-up questions on this blog topic.