V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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
ilumer
V2EX  ›  MySQL

mysql 联合索引的 column 数量 会影响到 B+树的阶吗?

  •  
  •   ilumer · 2022-03-23 11:56:45 +08:00 · 1017 次点击
    这是一个创建于 766 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如对于同一张表

    CREATE TABLE test(
    
    col_1 INT,
    
    col_2 INT,
    
    col_3 VARCHAR(11),
    
    col_4 VARCHAR(11)  )ENGINE = INNODB;
    CREATE idx_1 mul ON test(col_2,col_3,col_4);
    CREATE idx_2 mul ON test(col_2,col_3);
    
    

    这里联合索引中的 column 数量会影响到到索引树的阶吗,三个 column 组成的联合索引阶数要大于两个 column 组成的联合索引吗

    wqlm
        1
    wqlm  
       2022-03-23 16:20:35 +08:00
    是的,因为一个 innodb page 默认大小 16K ,索引字段越多,一个 page 中能存储的数量就越小,导致树变高(树的阶变大)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5140 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 03:49 · PVG 11:49 · LAX 20:49 · JFK 23:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.