Mysql – BigInt or Varchar for a large number I won’t ever sort / calculate on

myisamMySQL

I need to store users' Facebook IDs in a column in my DB.

The ID always consists of only digits, and can be as large as a number in excess of 500 million. Considering that I won't ever need to do any arithmetic, sorting or use relational operators on the values, what would be a better choice: BigInt or varchar ?

The value will always be unique and never non-existent (null)

The only operation I do is check for the existence of an ID in the database, i.e. the = operator.

Best Answer

varchar adds overhead:

  • length of the string needs stored (extra 2 bytes IIRC in MySQL) per field and in the index
  • requires more processing for collation on comparison

Saying that, what does the Facebook API describe the type as? Use the "native" one of course