Documentation Home
MySQL 5.7 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 35.1Mb
PDF (A4) - 35.2Mb
Man Pages (TGZ) - 256.4Kb
Man Pages (Zip) - 361.2Kb
Info (Gzip) - 3.4Mb
Info (Zip) - 3.4Mb
Excerpts from this Manual

MySQL 5.7 Reference Manual  / Optimization  /  Optimizing for MEMORY Tables

8.7 Optimizing for MEMORY Tables

Consider usingMEMORY tables for noncritical data that is accessed often, and is read-only or rarely updated. Benchmark your application against equivalentInnoDB orMyISAM tables under a realistic workload, to confirm that any additional performance is worth the risk of losing data, or the overhead of copying data from a disk-based table at application start.

For best performance withMEMORY tables, examine the kinds of queries against each table, and specify the type to use for each associated index, either a B-tree index or a hash index. On theCREATE INDEX statement, use the clauseUSING BTREE orUSING HASH. B-tree indexes are fast for queries that do greater-than or less-than comparisons through operators such as> orBETWEEN. Hash indexes are only fast for queries that look up single values through the= operator, or a restricted set of values through theIN operator. For whyUSING BTREE is often a better choice than the defaultUSING HASH, seeSection 8.2.1.20, “Avoiding Full Table Scans”. For implementation details of the different types ofMEMORY indexes, seeSection 8.3.8, “Comparison of B-Tree and Hash Indexes”.