数据库设计 - MySQL数据库主键问题
高洛峰
高洛峰 2017-04-17 16:19:42
0
3
902

前几天在项目组里,总监建议把所有数据表的主键设为字符串类型(UUID),由应用程序维护数据表的主键,问下这个主要是出于什么方面的考虑呢???
P.S. 我们用的MySQL数据库,存储引擎用的InnoDB,看了很多DBA的文章建议是说InnoDB类型的表最好是使用自增主键...

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
Ty80

UUID generates primary keys to avoid duplication of primary keys, and the program is easy to maintain. @wangcw explains it very well. As for the disadvantages, I have not encountered them yet due to limited experience

黄舟

As far as I understand, the advantages of using UUID are low repeatability, convenient automatic generation, and there is no need to consider the problem of repeated insertion failure of the primary key;
The reason why it is not recommended to use UUID: After the data volume reaches a certain value, index maintenance is very inconvenient, and the database performance is greatly reduced. Fragmentation organization also has a certain impact.

洪涛

If you use UUID, you have to maintain the primary key through the application. Isn’t this very cumbersome...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template