且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将一列设置为 mysql 表中的索引是否确保 O(1) 查找?

更新时间:2023-11-26 14:06:28

MySQL 的 MyISAM 或 InnoDB 存储引擎中的所有查找都不是 O(1) 搜索.这些存储引擎使用 B+Trees 来实现索引.他们能做的***的事情是 O(log2n) 次搜索.

None of the lookups in MySQL's MyISAM or InnoDB storage engines are O(1) searches. Those storage engines use B+Trees to implement indexes. The best they can do is O(log2n) searches.

MEMORY 存储引擎默认使用 HASH 索引类型,以及 B+Tree 索引类型.只有 HASH 索引可以实现 O(1) 查找.

The MEMORY storage engine uses a HASH index type by default, as well as the B+Tree index type. Only the HASH index can achieve O(1) lookups.

索引列的数据类型在任何一种情况下都不会改变这一点.

The data type of the indexed column doesn't change this in either case.

有关 MySQL 索引的更多信息,请阅读 http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html

For more on MySQL indexes, read http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html