so when there’s an index on a column, and you do a simple SELECT * FROM table WHERE indexed_column = value, is that a O(1) search? does it matter whether the contents indexed are integers or string?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.
The
MEMORYstorage 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.
For more on MySQL indexes, read http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html