Consider using 对于非经常访问的非关键数据,并且只读或很少更新,请考虑使用MEMORY
tables for noncritical data that is accessed often, and is read-only or rarely updated. MEMORY
表。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.InnoDB
或MyISAM
表对应用程序进行基准测试,以确认任何额外的性能都值得冒数据丢失的风险,或在应用程序启动时从基于磁盘的表复制数据的开销。
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. MEMORY
表的最佳性能,请检查针对每个表的查询类型,并指定用于每个关联索引(B树索引或哈希索引)的类型。On the 在CREATE INDEX
statement, use the clause USING BTREE
or USING HASH
. CREATE INDEX
语句中,使用USING BTREE
或USING HASH
子句。B-tree indexes are fast for queries that do greater-than or less-than comparisons through operators such as 对于通过>
or BETWEEN
. >
或BETWEEN
等运算符进行大于或小于比较的查询,B树索引速度很快。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. =
运算符查找单个值或通过IN
运算符查找受限值集的查询。For why 有关USING BTREE
is often a better choice than the default USING HASH
, see Section 8.2.1.23, “Avoiding Full Table Scans”. USING BTREE
通常比默认USING HASH
更好的原因,请参阅第8.2.1.23节,“避免全表扫描”。For implementation details of the different types of 有关不同类型MEMORY
indexes, see Section 8.3.9, “Comparison of B-Tree and Hash Indexes”.MEMORY
索引的实现细节,请参阅第8.3.9节,“B-树索引和哈希索引的比较”。