14.2.5.2 Clustered and Secondary Indexes
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的更多相关文章
- 14.8.9 Clustered and Secondary Indexes
14.8.9 Clustered and Secondary Indexes 每个InnoDB 表有一个特殊的索引称为 clustered index 用于存储数据. 通常, clustered in ...
- Clustered and Secondary Indexes
Clustered and Secondary Indexes secondary index A type of InnoDB index that represents a subset of t ...
- 在InnoDB,记录在 non-clustered indexes(也被称为secondary indexes) 包含了主键值
In InnoDB, the records in non-clustered indexes (also called secondary indexes) contain the primary ...
- Clustered和Nonclustered Indexes 各自得特点和区别及长短处
1 簇索引 簇索引对表的物理数据页中的数据按列进行排序然后再重新存储到磁盘上即簇索 引与数据是混为一体的它的叶节点中存储的是实际的数据由于簇索引对表中的数据一 一进行了排序因此用簇索引查找数据很快但由 ...
- 转 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 ...
- 转 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 ...
- mysql 锁2
官网地址 https://dev.mysql.com/doc/refman/5.5/en/innodb-transaction-isolation-levels.html 这里主要是说事务隔离级别,以 ...
- innodb_locks_unsafe_for_binlog分析
mysql数据库中默认的隔离级别为repeat-read. innodb默认使用了next-gap算法,这种算法结合了index-row锁和gap锁.正因为这样的锁算法,innodb在可重复读这样的默 ...
- 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 ...
随机推荐
- Android Bluetooth开发
原文地址:http://developer.android.com/guide/topics/wireless/bluetooth.html 翻译:jykenan 更新:2012.06.19 Andr ...
- 采用xml的方式保存数据
package com.example.myxmlmake; import java.io.File; import java.io.FileOutputStream; import java.uti ...
- WinDbg分析DUMP文件
1. 如何生成dump文件? 原理:通过SetUnhandledExceptionFilter设置捕获dump的入口,然后通过MiniDumpWriteDump生成dump文件: ...
- QList 和std::list的比较
QList QList<T> 是一个Qt通用容器类.它存储一序列的值,并且提供基于索引的数据访问方法和快速的插入和删除操作. QList<T>, QLinkedList< ...
- docker学习笔记5:利用commit命令创建镜像 和 删除本地镜像
一.概述 创建镜像有两种方法,一是用commit命令,二是用dockerfile方法(这个更常用,在下面文章介绍).本章介绍commit方法. 在介绍commit命令前,我们先回顾下对代码的版本控制, ...
- MONGODB的内部构造 FROM 《MONGODB THE DEFINITIVE GUIDE》
今天下载了<MongoDB The Definitive Guide>电子版,浏览了里面的内容,还是挺丰富的.是官网文档实际应用方面的一个补充.和官方文档类似,介绍MongoDB的内部原理 ...
- CCIE路由实验(6) -- 组播Multicasting
1.组播IGMP的各种情况2.PIM Dense-Mode3.PIM Sparse-Mode4.PIM双向树和SSM5.动态RP之auto-rp6.动态RP之BSR7.Anycast RP8.域间组播 ...
- Mysql zip 安装(windows)
Mysql Windows zip包安装 Mysql 下载地址: http://dev.mysql.com/downloads/mysql/ 下载windows 版本对应的zip,之后解压 在C:\P ...
- lsh341999的资源
懒得下载了,仔细研究: http://download.csdn.net/user/lsh341999/uploads/2
- Spring mvc之提交表单
表单内容: <body> <form action="user/login"> <table> <tr> <td>用户名 ...