索引是如何实现mvcc呢?
索引没有undolog,因此索引需要回表,通过回表得到数据的undolog,然后判定索引条目是否有效。但是如果索引本身不带事务id,那么如何知道其属于哪一个版本呢?如果每个索引条目都需要回表才能确定是否有效,那么全索引扫描不就是全表扫描了吗?如果主键变更索引又要如何处理?
https://dev.mysql.com/doc/refman/8.0/en/innodb-multi-versioning.html?open_in_browser=true
似乎是,二级索引的数据也是一样不删除,而是标记为删除,但是仍然存留在二级索引的b+树上,每个索引页会记录最近更新的事务id。而如何确定数据是否有效呢,回表,回表,回表,重要的事情说三遍,只有回表访问版本链才能知道readview是否能够看到这条记录的这个版本
If a secondary index record is marked for deletion or the secondary index page is updated by a newer transaction, the covering index technique is not used. Instead of returning values from the index structure, InnoDB looks up the record in the clustered index.