ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 8.7 优化 MEMORY 表 Consider using `MEMORY` tables for noncritical data that is accessed often, and is read-only or rarely updated. Benchmark your application against equivalent `InnoDB` or `MyISAM` 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 with `MEMORY` 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 the [CREATE INDEX](https://dev.mysql.com/doc/refman/8.0/en/create-index.html) statement, use the clause `USING BTREE` or `USING HASH`. B-tree indexes are fast for queries that do greater-than or less-than comparisons through operators such as `>` or `BETWEEN`. Hash indexes are only fast for queries that look up single values through the `=` operator, or a restricted set of values through the `IN` operator. For why `USING BTREE` is often a better choice than the default `USING HASH`, see [Section 8.2.1.21, “Avoiding Full Table Scans”](https://dev.mysql.com/doc/refman/8.0/en/table-scan-avoidance.html). For implementation details of the different types of `MEMORY` indexes, see [Section 8.3.9, “Comparison of B-Tree and Hash Indexes”](https://dev.mysql.com/doc/refman/8.0/en/index-btree-hash.html).