doushe2513 2011-02-23 12:42
浏览 52
已采纳

Mysql PK和FK char(36)vs int(10)

I have read that mysql can handle indexes and searches better if the tables keys are integers rather than char(36) UUID's.

Is it worth converting to int(10)?

NOTE: We only use 1 server and have currently have to plans to use multiple databases concurrently therefore removing one of the big reasons for using UUID. Our tables are also InnoDB if that makes a difference.

Thanks in advance.

  • 写回答

3条回答 默认 最新

  • duan02143 2011-02-23 12:47
    关注

    Usually RDBMS can handle Integer keys as PK more efficient, than other datatypes. The reason is how it build up the index for the column, so yes: As long as you dont require string (or other typed) keys, you should always use integers.

    However: CHAR(36) and INT(10) are far away from being equal, because a INT(10) is much smaller, than CHAR(36). I dont know, if you require so many different keys, but you should keep that in mind.

    Update, to complete the last paragraph: INT(10) is 32-Bit, CHAR(36) is 36 - ^Byte^ (= 288-Bit). This does not only mean, that INT consumes less space, it also means, that CHAR(36) has about 4 times more different keys.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀