- 不易於存儲:UUID太長,16字節128位,通常以36長度的字符串表示,很多場景不適用。
- 信息不安全:基於MAC地址生成UUID的算法可能會造成MAC地址泄露,這個漏洞曾被用於尋找梅麗莎病毒的制作者位置。
-
ID作為主鍵時在特定的環境會存在一些問題,比如做DB主鍵的場景下,UUID就非常不適用:
① MySQL官方有明確的建議主鍵要盡量越短越好[4],36個字符長度的UUID不符合要求。
All indexes other than the clustered index are known as secondary indexes. In InnoDB, each record in a secondary index contains the primary key
columns for the row, as well as the columns specified for the secondary index. InnoDB uses this primary key value to search for the row in the clustered index.
If the primary key is long, the secondary indexes use more space, so it is advantageous to have a short primary key.
-
② 對MySQL索引不利:如果作為數據庫主鍵,在InnoDB引擎下,UUID的無序性可能會引起數據位置頻繁變動,嚴重影響性能。
然后轉載一下這個:
https://www.cnblogs.com/wyq178/p/12548864.html
總結下
1.頁的利用率,頁面幾乎是被順序填充滿才產生分裂。
2.uuid分裂次數更多,對於已經填滿的頁面,因為無序很可能多次命中,產生分裂,進而產生更多不被填滿頁面。還有分裂本身的成本
3.頁高速緩存命中率低,需要更多的磁盤I/O,並且是隨機的