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. 【Linux】Linux 自己主动挂载NTFS格式移动硬盘

    1.首先下载ntfs-3g http://www.tuxera.com/community/ntfs-3g-download/ 2.解压 $tar zxvf ntfs-3g_ntfsprogs-201 ...

  2. C# 窗体在线2,8,16进制转换以及,在线更新时间

    class Program { static void Main(string[] args) { //十进制转二进制 Console.WriteLine(, )); //十进制转八进制 Consol ...

  3. 四、Nginx负载均衡upstream

    user www; worker_processes ; error_log /usr/local/nginx/logs/error.log crit; pid /usr/local/nginx/lo ...

  4. 读取sd卡下图片,由图片路径转换为bitmap

    public Bitmap convertToBitmap(String path, int w, int h) {             BitmapFactory.Options opts = ...

  5. stringstream clear()的疑问 - yuanshuilee的日志 - 网易博客

    stringstream clear()的疑问 - yuanshuilee的日志 - 网易博客 stringstream clear()的疑问   2013-09-05 08:43:13|  分类: ...

  6. JavaScript实现复制功能

    这两天在做Web前端时,遇到需求通过 js 实现文本复制的功能. 先不考虑浏览器的兼容性,看看各浏览器对复制功能的支持情况: 1.IE浏览器 ,解决方法有三种,代码如下: function copy( ...

  7. IP数据报首部校验和算法

    当用google搜索IP数据报首部校验和算法的时候,总是看到的是代码,没有看到其过程,于是就有了此文,如有错误请指正.文章省略一点,呵呵   IP/ICMP/IGMP/TCP/UDP等协议的校验和算法 ...

  8. openssl生成pem,密钥证书的创建

    使用OpenSSL生成证书 首先得安装OpenSSL软件包openssl,安装了这个软件包之后,我们可以做这些事情: o Creation of RSA, DH and DSA Key Paramet ...

  9. 关于callContext

    coding们肯定有这种需求,在程序中,方法一级级调下去,比如A->b->C->D.... ->Z.在调用过程中,希望在调用函数之间传递一些数据,常见的是将特定的数据从高往低处 ...

  10. 不用SWIG,Go使用C++代码的方式

    将C++代码用C作一次封装,就可以让Go调用了. 这是一个C++头文件: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #ifndef CGO_CPPGO_C ...