HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

BigInt or Varchar for a large number I won't ever sort / calculate on

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
numberwonvarcharlargesortforcalculatebigintever

Problem

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.

Solution

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

Context

StackExchange Database Administrators Q#17280, answer score: 4

Revisions (0)

No revisions yet.