14.2.5.2 Clustered and Secondary Indexes  :

每个InnoDB 表 有一个特别的索引称为clustered index  行数据存储的地方。

典型的,clustered index是主键的同义词,得到最好的查询,插入性能,和其他数据库操作,

你必须了解InnoDB 使用clustered index 来优化最常见的查询和DML操作在每个表上。

当你定义一个PRIMARY KEY 在你的表上,InnoDB 使用它作为一个 clustered index.

定义一个主键对于每个表在你创建的时候。

如果没有逻辑的唯一和no-null列或者列的组合,增加一个自增列,它的值是自动填充的。

如果你没有定义一个主键为你的表,MySQL 定位第一个UNIQUE index ,所有的key 列是NOT NULL的 ,

InnoDB 使用它作为clustered index.

mysql> show create table AssignClientManager\G;
*************************** 1. row ***************************
Table: AssignClientManager
Create Table: CREATE TABLE `AssignClientManager` (
`sn` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键(自增字段)',
`clientSn` int(11) NOT NULL COMMENT 'clientSn 映射',
`clientManagerSn` int(11) NOT NULL COMMENT 'clientManagerSn 映射',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '分配的客户经理记录状态 1-生效,2-失效',
`createdTime` datetime NOT NULL COMMENT '创建时间',
`updatedTime` datetime DEFAULT NULL COMMENT '修改时间',
PRIMARY KEY (`sn`),
KEY `AssignClientManager_idx1` (`clientSn`)
) ENGINE=InnoDB AUTO_INCREMENT=4919 DEFAULT CHARSET=utf8 COMMENT='客户经理分配表'
1 row in set (0.00 sec) 如果表没有主键或者合适的 UNIQUE index,InnoDB 内部产生一个隐藏的clustered index在虚构的列 包含了row ID值。 记录是按ID 排序 InnoDB 分配给记录。 How the Clustered Index Speeds Up Queries :Clustered Index 如何加速查询; 通过clustered index 访问记录 是快速的 因为 Index 搜索直接指向所有的数据行。 如果表是大的,clustered index 结构通常会接收磁盘I/O 操作当与使用一个不同的Page 比较存储组织的时候 (比如,MyISAM 使用一个文件用于数据记录和其他的索引记录) How Secondary Indexes Relate to the Clustered Index Secondary Indexes和 Clustered Index的关系: 所有的索引除了clustered index 都被称为secondary indexes. 在InnoDB,每个记录在一个secondary index 包含 主键列 对于记录, 以及列指定的用于secondary index. InnoDB使用主键列值来搜索 clustered index.中的记录 如果主键列是长的, secondary indexes 会使用更多的空间,所以一个短的主键是有利的。

14.2.5.2 Clustered and Secondary Indexes的更多相关文章

  1. 14.8.9 Clustered and Secondary Indexes

    14.8.9 Clustered and Secondary Indexes 每个InnoDB 表有一个特殊的索引称为 clustered index 用于存储数据. 通常, clustered in ...

  2. Clustered and Secondary Indexes

    Clustered and Secondary Indexes secondary index A type of InnoDB index that represents a subset of t ...

  3. 在InnoDB,记录在 non-clustered indexes(也被称为secondary indexes) 包含了主键值

    In InnoDB, the records in non-clustered indexes (also called secondary indexes) contain the primary ...

  4. Clustered和Nonclustered Indexes 各自得特点和区别及长短处

    1 簇索引 簇索引对表的物理数据页中的数据按列进行排序然后再重新存储到磁盘上即簇索 引与数据是混为一体的它的叶节点中存储的是实际的数据由于簇索引对表中的数据一 一进行了排序因此用簇索引查找数据很快但由 ...

  5. 转 MYSQL InnoDB Record, Gap, and Next-Key Locks

    http://dev.mysql.com/doc/refman/5.0/en/innodb-record-level-locks.html InnoDB has several types of re ...

  6. 转 mysql Next-Key Locking

    原文:http://dev.mysql.com/doc/refman/5.5/en/innodb-next-key-locking.html 14.5.2.5 Avoiding the Phantom ...

  7. mysql 锁2

    官网地址 https://dev.mysql.com/doc/refman/5.5/en/innodb-transaction-isolation-levels.html 这里主要是说事务隔离级别,以 ...

  8. innodb_locks_unsafe_for_binlog分析

    mysql数据库中默认的隔离级别为repeat-read. innodb默认使用了next-gap算法,这种算法结合了index-row锁和gap锁.正因为这样的锁算法,innodb在可重复读这样的默 ...

  9. MySQL 5.6 Reference Manual-14.3 InnoDB Transaction Model and Locking

    14.3 InnoDB Transaction Model and Locking 14.3.1 InnoDB Lock Modes 14.3.2 InnoDB Record, Gap, and Ne ...

随机推荐

  1. BZOJ 1072 [SCOI2007]安排perm 如压力DP

    意甲冠军:联系 方法:状压DP? 题解:这题事实上没啥好写的.不算非常难,推一推就能搞出来. 首先看到这个问题,对于被d整除这个条件,非常easy就想到是取余数为0,所以想到可能状态中刚開始含有取余数 ...

  2. [LeetCode] Decode Ways [33]

    题目 A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A ...

  3. sencha touch笔记(5)——DataView组件(1)

    1.DataView组件可以显示列表,图像等等的组件或者元素,特别适用于数据仓库频繁更新的情况.比如像显示新闻或者微博等等的很多相同样式的组件的列表这种一次性从后台或者数据源拿取很多数据展示的样式.比 ...

  4. 17-UIKit(UIView的动画)

    2. UIView的动画 UIView类本身具有动画的功能 2.1 概念 由UI对底层Core Animation框架的封装 可以轻松简单的实现动画效果 2.2 两种使用方式 1> Block ...

  5. android sdk国内快速更新下载

    Android SDK在线更新镜像服务器 http://www.androiddevtools.cn/ 目前正在使用的是:包含详细的配图流程 http://android-mirror.bugly.q ...

  6. Android 播放声音

    public static void PlayAlarmRing(Context mContext) { Uri alert = RingtoneManager.getDefaultUri(Ringt ...

  7. Jquery学习笔记: attr和 prop的区别,以及为html标签自定义属性

    一.自定义html标签属性 对于html文件中的html标签,可以自定义属性,如: <a href="#" id="link1" action=" ...

  8. 基于visual Studio2013解决C语言竞赛题之0704字符串长度

     题目

  9. 有关oppo蝴蝶解锁的三D技术

    oppo手机的界面设计也是很漂亮的.在很多界面中使用了3D技术塑造出了大量华丽的效果.在蝴蝶解锁中使用了两个对称的三D变幻,宛如蝴蝶翅膀上美丽的花纹.在受到用户点击后,随风缓慢上下扇动,充满浪漫的动感 ...

  10. POJ 1700 cross river (数学模拟)

                                                                                                       ...