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. WinForm 小程序 NotePad

    运行效果: 代码: using System; using System.Collections.Generic; using System.ComponentModel; using System. ...

  2. Inter IPP 跟 Microsoft V100编译器区别

    最近做项目用了两个编译器,由于是一种精度的算法计算,对计算的精度要求非常高,同时都用的float型,发现inter的结果比vs的结果好许多.但是不知道是什么原因,最后测试发现,是两个编译器的问题.   ...

  3. 嵌入式:使用dd命令制作烧写文件

    1. 使用dd命令制作烧写文件 环境: bootargs=mem=64M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 mtd ...

  4. BZOJ 2038: [2009国家集训队]小Z的袜子(hose) ( 莫队 )

    莫队..先按sqrt(n)分块, 然后按块的顺序对询问排序, 同块就按右端点排序. 然后就按排序后的顺序暴力求解即可. 时间复杂度O(n1.5) --------------------------- ...

  5. Android下调用收发短信邮件等

    Android下调用收发短信邮件等 1,调web浏览器Uri myBlogUri = Uri.parse("http://xxxxx.com");returnIt = new In ...

  6. Android移动view动画问题

    http://www.cnblogs.com/eoiioe/archive/2012/08/29/2662546.html Android写动画效果不是一般的麻烦,网上找了好久,终于解决了动画的问题, ...

  7. Home键的获取监听,安卓4.0后就不能在onkeydown方法中获取了。怎么办。

    Android下得到Home键按下的消息   在Android下,并不能通过onKeyDown这样的事件来截获Home键的消息,其原因在Android的文档中已经明确的说过了 public stati ...

  8. 如何在VMware中修改Mac OS的屏幕分辨率

    关于mac os分辨率问题:方法一:临时方法,只对当次启动有效,即在启动倒计时的时候,回车,等待输入参数是输入如下文本:“Graphics Mode"="1280x800x32@6 ...

  9. mysql各版本区别

    MySQL 的官网下载地址:http://www.mysql.com/downloads/ 在这个下载界面会有几个版本的选择. 1. MySQL Community Server 社区版本,开源免费, ...

  10. 用 PS 复制权限

    用 PS 复制权限 我们要把源计算机上的文件权限复制到目的计算机上. get-acl .\s.txt | Export-Clixml sddl.xml 把 s.txt 文件的权限保存到 sddl.xm ...