mysql innodb 主键

本文介绍了MySQL InnoDB存储引擎中主键的设计原理及其对数据存储和索引的影响。主键决定了数据在主要数据文件中的物理存储顺序,并且复制到每个索引的每一行中,因此选择合适的主键类型对于提高查询效率至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • http://blog.johnjosephbachir.org/2006/10/22/everything-you-need-to-know-about-designing-mysql-innodb-primary-keys/
  • The primary key determines the order in which the data is physically stored in the main data file, aka “the clustered index”. Another way of saying this: the main data file is a B-tree index that directly contains all of a table’s columns, and the key on this B-tree is the primary key. This can result in one less I/O operation (compared to MyISAM) on many queries.
  • The primary key is what is used to associate all of a table’s indexes with the main data file. So the primary key is replicated in every row of every index.
如果不显示的指定主键的话,mysql会默认指定一个隐式的主键,而且是6字节的,
主键应该是有序的
主键应该越小越好,Because the primary key is replicated in every entry of every index, 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值