MySQL - Storage Engine - MEMORY

Each MEMORY table is represented on disk by an .frm format file in the database directory. Table data and indexes are stored in memory.

In-memory storage results in very fast performance.

MEMORY table contents do not survive a restart of the server. The table structure itself survives, but the table contains zero data rows after a restart.

MEMORY tables use up memory, so they should not be used for large tables.

MySQL manage query contention for MEMORY tables using table-level locking. Deadlock cannot occur.

MEMORY tables cannot contain TEXT or BLOB columns.

The MEMORY storage engine was formerly called the HEAP engine. MySQL server still recognized HEAP for backward compatibility.

The MEMORY storage engine supports two indexing algorithms, HASH and BTREE.

MEMORY tables use hash indexes by default. This index algorithm provides very fast lookups for all operations that use a unique index. However, hash indexes are usable only for comparisons that use the = or <=> operator.

The BTREE index algorithm is preferable if the indexed column will be used with comparison operators other than = or <=>. For example, BTREE can be used for range searches such as id < 100 or id BETWEEN 200 AND 300.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License