MySQL 5.5 Community Server
MySQL 5.6 Community Server
Percona Configuration Wizard
XtraBackup 搭建主从复制
Great Sites on MySQL
Percona
MySQL Performance Blog
Severalnines
推荐管理工具
Sequel Pro
phpMyAdmin
推荐书目
MySQL Cookbook
MySQL 相关项目
MariaDB
Drizzle
参考文档
http://mysql-python.sourceforge.net/MySQLdb.html
Aresxue
V2EX  ›  MySQL

mysql 删除记录会删除次级索引吗?

  •  
  •   Aresxue · Sep 4, 2019 · 5297 views
    This topic created in 2482 days ago, the information mentioned may be changed or developed.

    mysql 的默认删除是将行记录中的 delete_mask 从 0 修改为 1,这样该行就可以被复用了,但是非聚簇索引存在别的页,会根据行记录的聚簇索引反向查到所有非聚簇索引然后把它们删除吗?

    Supplement 1  ·  Sep 4, 2019
    次级索引会不会删除?如果删除是不是立即删除?
    5 replies    2019-09-06 11:05:14 +08:00
    vino2014zly
        1
    vino2014zly  
       Sep 4, 2019
    设想一下如果不删除,查询走覆盖索引的时候咋办?
    Aresxue
        2
    Aresxue  
    OP
       Sep 4, 2019
    @vino2014zly 走了之后并找不到聚簇索引,不影响结果集,但是对性能会有影响。
    ilumer
        3
    ilumer  
       Sep 5, 2019
    @Aresxue 走了索引覆盖 就和聚簇索引没啥关系了
    Aresxue
        4
    Aresxue  
    OP
       Sep 6, 2019
    @ilumer 索引覆盖是比较理想的情况,在实际中一般还要根据指针再去找聚簇索引获取整个行。我的疑惑点在于这些二级索引此时是如何处理的,如果是和其他行共有的二级索引也不可能直接删除吧?但是如果二级索引没有指向聚簇索引的记录了此时是不是会删除?删除是当前线程去操作还是异步 purge 线程去清理。
    ilumer
        5
    ilumer  
       Sep 6, 2019
    @Aresxue 超纲了 菜鸡不会 瞎猜不会删除
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2472 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 6b34f497 · 41ms · UTC 10:58 · PVG 18:58 · LAX 03:58 · JFK 06:58
    ♥ Do have faith in what you're doing.