How short can a GUID be?

前端 未结 6 1870
离开以前
离开以前 2021-02-07 04:01

I know the standard GUIDs. Can they be made shorter? What is the theory behind it?

6条回答
  •  旧时难觅i
    2021-02-07 04:53

    Depending on your application, it really comes down to how big your "G"(Global) is in your application.

    "GUID", Global Unique ID. Typical modern "generic" GUIDs are designed for any application, and their "G", their, "Global", is literally that. Global. World wide. Across applications, nations, geography, everything. 16 Bytes is a LOT of information.

    Now, if IN YOUR APPLICATION, your "G" isn't that big, if you have not expectation, or intention of "G" being Global in a World sense, rather than simply "global" in the application space sense, then you can readily reduce the size to the scope of your application.

    Got four divisions in your company, never going to have more? 2 bits -- 0, 1, 2, 3 is a big enough "GUID" for this task. Clearly, this is a contrived application.

    We've learned in the past the consequence of "limiting Bits" when we slaved through the Y2K problems. So, "bits are cheap" is a valid enough reason to NOT limit your GUID size, and to err on the side of "too many bits for now". But, truth be told, many applications simply ARE limited, many applications may well generate a lot of a data, or be bandwidth constrained to where there is no need for a 16 byte GUID, and using one impacts performance and resources.

    So, understand the concept of the GUID, and how it applies to your applications. Then you can make it any size necessary.

提交回复
热议问题