mysql - 表的主键都是varchar(64),有什么不好?
ringa_lee
ringa_lee 2017-04-17 15:06:53
0
4
888

见识到一个java项目,mysql数据库,所有表的主键都是varchar(64)

ringa_lee
ringa_lee

ringa_lee

reply all(4)
刘奇

Compared to int, varchar takes up more disk space, has more disk IO, and has more memory bandwidth. This is especially obvious in innodb. The leaf page of the secondary index of the innodb table must store the value of the primary key. If the primary key is varchar, the size of the secondary index will be larger. Moreover, the varchar primary key will be slower in comparison. It is easy to send non-sequential insertion of data during insertion, resulting in fragmentation. The index tree efficiency is lower than that of int

大家讲道理

This is a sign of laziness!

巴扎黑

Very wasteful and unprofessional.

If it is char() type, the value given is 5. Then regardless of whether there is a value in the field, even null will occupy 5×当前数据库编码字节. varchar() will first use one byte to record the maximum range of the type. If no value is passed, it will only record the first byte. If it is passed, the content within the maximum range of the value will be stored.

The hard disk space occupied by each record of the remaining fields will be discussed separately.

阿神

Everything said above is correct
Maybe the content he recorded is UUID
Many jsp programming libraries are like this when designing libraries, I don’t know why

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!