1

I'm currently getting facebookids from facebook and storing them in a mysql database. The ids are around 17 characters long ex: 10211604228890284.

I'm currently storing them as BigInt primary keys, however I've been told that this can increasingly reduce performace.

would storing them as primary key string work?, or is there a better way of doing this.

here is my current code:

Create table users( 
   id bigint AUTO_INCREMENT,
   primary key (id)
);

CREATE TABLE users_friends(
   id bigint,
   friend_id  bigint,
   Primary Key (id,friend_id), 
   Foreign Key (id) REFERENCES users(id),
   Foreign Key (friend_id) REFERENCES users(id)
);
slimboy
  • 1,633
  • 2
  • 22
  • 45
  • 1
    the storage size of a BIGINT is 8 bytes, the storage size of the equivalent varchar string would be 17+1 bytes ... why you thing a string would perform better? – fthiella Mar 02 '17 at 21:33
  • "*I've been told that this can increasingly reduce performance.*" I'd verify that before you go rewriting your schema. I'd be surprised if a string will run faster than a bigint especially on a 64 bit machine. I'll bet that advice was *as compared to integers*. – Schwern Mar 02 '17 at 23:07

0 Answers0