mysqlxbox-live

What's the most efficient way to store XUIDs on SQL?


The official Xbox Auth documentation refers to XUID as an unsigned int64, and therefore, I expected the SQL equivalent, BIGINT, to be the most efficient way to store it on a MySQL database.

However, I found out that many programmers are storing XUIDs on their databases as VARCHAR(20), after some research these are the key differences I found between these data types:

  1. VARCHAR(20) uses up to 21 bytes (depending on the length of the text)
  2. BIGINT always uses 8 bytes, independently of the length of the text.

This is how this question came to my mind, what is the most efficient way to store XUIDs on SQL?


Solution

  • If a XUID is a 64-bit unsigned integer, then it can have values from 0 to 18,446,744,073,709,551,615. So VARCHAR(10) will not be large enough; you would need to use VARCHAR(20).

    It should be slightly more efficient (and use a little less database disk space) to store it as a BIGINT UNSIGNED (always eight bytes) than VARCHAR(20) (up to 21 bytes depending on the magnitude of the number being stored, assuming a one-byte-per-digit character set for the column).