V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
thomaswang
V2EX  ›  程序员

mysql 索引问题

  •  
  •   thomaswang · 2017-08-11 23:54:25 +08:00 · 2353 次点击
    这是一个创建于 2421 天前的主题,其中的信息可能已经有所发展或是发生改变。
    msyql B+索引问题,比如:name 字段加了索引, 当插入一条数据的时候,是不是要对该条数据的 name 值进行 hash,把值转换成整数,然后插入到 B+树里面,如果是这样的,那么这个 hash 算法是什么呢
    11 条回复    2017-08-12 12:38:42 +08:00
    iEverX
        1
    iEverX  
       2017-08-12 01:44:38 +08:00 via Android
    不做 hash 吧,否则怎么有序
    thomaswang
        2
    thomaswang  
    OP
       2017-08-12 07:59:52 +08:00 via iPhone
    @iEverX 不 hash 怎么把张三李四排序呢
    tb4649120073rs
        3
    tb4649120073rs  
       2017-08-12 09:30:16 +08:00
    @thomaswang 按字符串比较大小啊...
    1010011010
        4
    1010011010  
       2017-08-12 10:04:40 +08:00
    gbk 排序?
    limhiaoing
        5
    limhiaoing  
       2017-08-12 10:28:59 +08:00 via iPhone
    @thomaswang
    不 hash 怎么就不能对字符串排序了?
    SoloCompany
        6
    SoloCompany  
       2017-08-12 12:12:43 +08:00 via iPad
    hash 和 b+,楼主是走串场了吧
    thomaswang
        7
    thomaswang  
    OP
       2017-08-12 12:13:20 +08:00
    @limhiaoing 哦,你确定 mysql 里面是按字符串排序,对吗
    thomaswang
        8
    thomaswang  
    OP
       2017-08-12 12:14:31 +08:00
    @SoloCompany 我是不懂,mysql 是直接拿字符串来比较大小,然后插入到 B+树的吗
    thomaswang
        9
    thomaswang  
    OP
       2017-08-12 12:15:50 +08:00
    @tb4649120073rs 你确定 mysql 是拿字符串比较的,对吗
    SoloCompany
        10
    SoloCompany  
       2017-08-12 12:23:06 +08:00 via iPad
    @thomaswang 不是字符串顺序的话,那 order by 怎么办,难道是 order by hash ?另外还有个概念叫 collation 你先了解一下
    thomaswang
        11
    thomaswang  
    OP
       2017-08-12 12:38:42 +08:00
    @SoloCompany 哦,我先看看,多谢,有啥好点的书,可以推荐不
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   971 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 20:22 · PVG 04:22 · LAX 13:22 · JFK 16:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.