Home  >  Article  >  Database  >  InnoDB的索引_MySQL

InnoDB的索引_MySQL

WBOY
WBOYOriginal
2016-06-01 13:51:58679browse

InnoDB的索引分成primary key和second index。在InnoDB的实现中,主键就是cluster index,即是说InnoDB的数据是按照主键的顺序排序的。可能有同学会问,那如果InnoDB没有主键怎么办?放心,InnoDB会为为你选择一个的:1、如果有存在not null的unique index,那么InnoDB就将该索引作为主键;2、否则就自己内建一个类似rowid的列。所以InnoDB的cluster index一定存在,并且有且仅有一个。主键指向了具体的数据,而second index指向的是主键。所以在查找时如果使用的是second index,那么先要找到去对应的主键,然后才能找到对应的数据。
cluster index的优点从其特性就可以看出,对于index range读的性能是很好的,不过也有很多不足。对于我来讲,最大的问题就是在插入数据的时候太慢。曾经重新导过一个大约1.2亿行左右的表,开始的时候插入性能有1w+ row/s,到了后来只有80+ row/s欢迎上网易彩票买彩票啊~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn