MySQL 聚集索引和非聚集索引
MySQL 索引 面试 About 365 words聚集索引
聚集索引确定表中数据的物理顺序,每一行数据按照聚集索引物理上排序。
InnoDB存储引擎必须有且仅有一个聚集索引。
聚集索引存储的是这一行的数据本身(不是指针)。
必要要有聚集索引,并不代表一定要有主键。
- 如果定义了主键,主键就是聚集索引。
- 如果没有定义主键,第一个非空
not null且唯一unique的列是聚集索引。 - 如果没有符合的列,
MySQL就会自动创建一个隐藏的row id作为聚集索引。
非聚集索引
除了聚集索引以外的索引都是非聚集索引,分成普通索引、唯一索引、全文索引。
非聚集索引就像新华字典的偏旁字典,它的结构顺序与实际存放顺序不一定一致。
非聚集索引存储的是这一行的数据的主键的值(也不是指针)。
非聚集索引二次查询问题
可使用MySQL的覆盖索引解决。
可参考之前文章:MySQL中的覆盖索引
Views: 3,168 · Posted: 2021-05-19
———         Thanks for Reading         ———
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Prev Post
Today In History
- React ECharts 添加事件后控件多次绘制导致闪烁多次 Views: 20 · Posted: 2026-04-07
- Spring Boot OpenFeign 配置 HTTPS 客户端证书 Views: 2,443 · Posted: 2024-04-07
- VSCodium 代替 VS Code Views: 4,191 · Posted: 2023-04-07
- GitHub 提交了生产环境账号密码撤销办法 Views: 2,843 · Posted: 2022-04-07
- Java 中的锁 ReentrantLock Views: 2,872 · Posted: 2021-04-07
- Spring Boot 中的 ApplicationRunner 和 CommandLineRunner Views: 4,611 · Posted: 2020-04-07
- MySQL 命令行纵向打印 Views: 3,644 · Posted: 2019-04-07
- MySQL 存储 IP 地址 Views: 4,262 · Posted: 2019-04-07
- MySQL 字符串拼接 Views: 4,924 · Posted: 2019-04-07
- SQL 删除重复记录且保留一条 Views: 2,969 · Posted: 2019-04-07
- MySQL 查询重复数据 Views: 3,226 · Posted: 2019-04-07
- MySQL 自动更新时间戳及默认时间戳 Views: 6,814 · Posted: 2019-04-07
- MySQL 查询冗余索引 Views: 4,172 · Posted: 2019-04-07
- Ubuntu 系统升级 MySQL 版本 Views: 4,069 · Posted: 2019-04-07
- MySQL 查看运行的是哪份配置文件 Views: 3,824 · Posted: 2019-04-07
- MySQL 严格模式引起的问题 Views: 2,624 · Posted: 2019-04-07
- MySQL 最后一次查询花费时间 Views: 4,233 · Posted: 2019-04-07
- MySQL 查看配置文件路径 Views: 4,590 · Posted: 2019-04-07
- MySQL 时间相差了 13 小时 Views: 3,933 · Posted: 2019-04-07
- MySQL server has gone away Views: 3,919 · Posted: 2019-04-07
- MySQL 存储 Emoji 表情 Views: 2,771 · Posted: 2019-04-07
- MySQL 查看数据储存引擎 Views: 2,547 · Posted: 2019-04-07
- MySQL 查看有多少个连接 Views: 3,379 · Posted: 2019-04-07
- MySQL 数据库设置 root 密码 Views: 2,664 · Posted: 2019-04-07
- MySQL 开启日志 Views: 2,884 · Posted: 2019-04-07
- MySQL 事务 Views: 3,147 · Posted: 2019-04-07
- MySQL 视图 Views: 3,428 · Posted: 2019-04-07
- MySQL 内置函数之时间函数 Views: 3,263 · Posted: 2019-04-07
- MySQL 内置函数之数学函数 Views: 3,272 · Posted: 2019-04-07
- MySQL 内置函数之字符串函数 Views: 3,685 · Posted: 2019-04-07
- MySQL 外键 Views: 3,514 · Posted: 2019-04-07
- MySQL 分页 Views: 2,928 · Posted: 2019-04-07
- MySQL 排序 Views: 2,450 · Posted: 2019-04-07
- MySQL 分组 Views: 3,066 · Posted: 2019-04-07
Browsing
Refresh
Loading...
- PostgreSQL 重置序列序号 Views: 3651
- Next.js 初始化工程 Views: 517
- Python 基础语法 Views: 3128
- Spring Boot 在拦截器中获取 Controller 中的注解 Views: 3738
- HTML iframe 设置不显示滚动条和边框 Views: 7721
- CSS 网站信息标签放置于浏览器底部 Views: 1417
- Linux sed 命令查看文件指定行数内容 Views: 5830
- Linux scp 远程主机之间传输文件 Views: 1885
- ECharts axisPointer 显示十字准星指示器 Views: 148
- 使用 ffmpeg 剥离视频中的音频 Views: 6744